Image Diff Checker
Operator: Abdulla Al Fahad. How tools are built and checked
Looking at two screenshots and deciding whether anything changed is a job the eye does badly. A button two pixels lower, a grey that drifted from #333 to #343434, a missing icon in a corner: each is easy to miss and easy to see once something points at it. This checker puts a baseline image and a new image on one canvas, compares them pixel by pixel, and paints the differences red on a faded copy of the original.
It is built for the review step before a release, a design hand-off or a bug report, where the question is not just whether the images differ but how much and where. You get a mismatch count, a percentage of the area, a pass or fail against a tolerance you set, and four ways of looking at the two pictures. Nothing is uploaded; both images are decoded and compared in the tab.
Key features
- Baseline and new image slots that take a dropped file, a chosen file or a pasted screenshot (Ctrl+V fills A first, then B)
- A threshold slider from 0 to 1 and a switch for counting anti-aliased pixels as differences
- Mismatched pixels, percentage of the area, colour changes, ignored anti-aliasing pixels and a pass or fail line against a tolerance in percent
- Four views in a keyboard-navigable tab list: diff overlay, side by side, swipe and onion skin
- Size mismatch handling on a shared top-left canvas, with both original sizes reported
- Swap A and B, and download the diff as a PNG named diff-first-vs-second.png
- Row-by-row processing with a progress bar and a Cancel button for large images
How pixels are compared, and what counts as a change
Each slot accepts a PNG, JPG, WEBP, BMP or GIF up to 25 MB and 50 megapixels. The format is judged from the file's first bytes rather than its extension. A GIF is read at its first frame only. HEIC photos are refused with a request to export them as JPG. The two images are compared together on a shared canvas, and that canvas may not exceed 25 megapixels; a larger pair gets a message naming the size and the limit, not a frozen tab.
Colour distance is measured in YIQ space, the way the open-source pixelmatch library does it, after blending any transparency onto white. A pixel counts as changed when its squared distance exceeds 35215 times the square of the threshold. At the default threshold of 0.1 that is a distance of about 352, which ignores the tiny differences JPG compression adds and still catches a button turning from blue to green. At 0 almost any difference counts; at 1 only the most extreme black-to-white change would.
Anti-aliasing detection decides whether a changed pixel belongs to a soft edge. When it does, the pixel is painted yellow and counted separately, and it is not part of the mismatch total. A pixel passes this test when its neighbourhood runs from darker to lighter and the extreme neighbour sits in a flat area in both images. Switch the option on to count those pixels as changes instead. The test is a heuristic: it is good at text and shape edges that moved a little, and it can occasionally excuse a real change that happens to look like one.
When the images differ in size, they are placed at the top left of a canvas as wide as the wider image and as tall as the taller one. Pixels covered by only one of the two images count as mismatched and are drawn blue, and the report gives that number on its own line. If one image is wide and short and the other narrow and tall, a corner belongs to neither; those pixels are drawn pale grey and left out of the mismatch count but stay in the total area, which is the denominator for the percentage.
How it works
Both images are drawn onto canvases of the union size and their pixels read out as RGBA bytes. The loop then visits each pixel. If its colour is byte-identical in both images the distance is zero and it is painted as a pale grey version of image A, at 10 percent strength so the red marks stand out. Otherwise the YIQ distance is computed and compared with the limit.
For a pixel over the limit and with anti-aliasing detection on, the checker looks at its eight neighbours in image A and then in image B. It counts neighbours that match the pixel exactly (an edge pixel starts with one point), and gives up as soon as more than two match, because a flat region is not an edge. It records the darkest and the brightest neighbour. If either extreme is missing the pixel is not anti-aliasing. Otherwise the extreme neighbour must also have more than two identical neighbours of its own in both images. Passing in either image excuses the pixel.
To keep the page responsive, the rows are processed in blocks of roughly 400,000 pixels, with a pause between blocks that lets the browser redraw the progress bar. Moving the threshold or the anti-aliasing switch starts a new comparison after a quarter of a second, and a newer run silently replaces an older one.
When to run it
- Checking a redesigned page against the production screenshot before sign-off, with a written tolerance for the review
- Finding what changed between two exports of the same Figma frame or slide when the file names say nothing
- Attaching a diff PNG to a bug report so the developer sees the broken area rather than reading a description
- Comparing a scan or a render before and after a colour correction to see where the correction reached
- Confirming that a recompressed or resized image still matches the original closely enough to publish
Running a check
- Put the baseline in Image A and the new version in Image B, by dropping, choosing or pasting.
- Leave the threshold at 0.1 for screenshots, or lower it toward 0.02 for flat artwork where any change matters.
- Set the tolerance, in percent of the area, that should still count as a pass.
- Read the verdict and the counts under Result, then switch between the four views to find the changes.
- Download the diff PNG to attach it to a ticket or a review comment.
Example
Two 800 by 600 screenshots of one page: a 140 by 36 pixel button was recoloured, and a heading moved down 1 pixel
Image A 800 x 600 baseline
Image B 800 x 600 new build
Threshold 0.1 anti-aliasing: ignored tolerance 0.1%
Union canvas 800 x 600 = 480,000 pixelsWhat the report shows
Changed (colour) 5,040 the button, 140 x 36
Anti-aliasing ignored hundreds edges of the shifted heading, painted yellow
Mismatched pixels 5,040
Mismatch of area 5,040 / 480,000 = 1.05%
Verdict Fail: above the 0.1% tolerance (480 pixels allowed)Tips for best results
- Screenshot the two versions at the same browser width and zoom. A different size does not stop the comparison, but everything past the smaller image is flagged blue and drowns out the real changes.
- Raise the threshold to 0.15 or 0.2 when one image is a JPG. Compression noise spreads faint differences across the whole picture, and a looser threshold keeps them from adding up to a failing percentage.
- Use the swipe view to see a change in context and the diff overlay to count it. The overlay shows where, the swipe shows what.
- Set the tolerance from the area you are willing to accept. On an 800 by 600 page, 0.1 percent is 480 pixels, about one 22 by 22 pixel icon.
- Swap A and B when you pasted them in the wrong order. Only the sign of the colour difference changes, and the counts stay the same.
Limits
There is no region masking. A clock, a date or an ad slot that changes every load will count as a mismatch each time, so crop those out of both screenshots first.
A whole page that shifted by several pixels reports as a very large mismatch. The tool does not search for an alignment; it compares position by position.
Anti-aliasing detection is a heuristic. Switch it off for pixel-art or icon work where a single edge pixel changing is the very thing you are looking for.
Images with an embedded colour profile are decoded through the browser's colour management, so two files that differ only in profile can differ in pixels here, and the same file may differ slightly between browsers.
A GIF is compared at its first frame only, and a pair larger than 25 megapixels together is refused rather than shrunk, because shrinking would hide small changes.
Common errors and how to fix them
- The two images together span more than 25 megapixels
- Crop both images to the area you care about, or scale them down by the same factor before loading them. The comparison needs both on one canvas, so the larger of the two widths and heights sets the cost.
- The report is almost entirely blue
- The images have very different sizes. Re-capture them at the same dimensions, or crop the larger one to the size of the smaller, so only real changes remain.
Best practices
- Keep a baseline folder of PNG screenshots rather than JPG; lossless files make the percentage meaningful over time.
- Write the tolerance down next to the result. A pass at 0.5 percent and a pass at 0.01 percent mean different things.
- Look at the yellow pixels once in a while. A lot of them on one spot means an edge moved, which is a layout change even though it is not counted.
Reading the four views
The diff overlay is the one to count from. Red is a changed pixel, yellow is a soft edge that was excused, blue is area that exists in only one image, and the grey wash is everything that matched. Side by side shows A, B and the diff in a row on a wide screen and stacks them on a phone. Swipe slides a divider between A and B, so you can drag it across a suspect area and watch it flip. Onion skin blends the two images with a slider from all A to all B, which makes a moved element show up as a ghost.
The views use the same shared canvas, so a size difference shows as empty space on the smaller image in every view.
What stays in your browser
Both images are decoded and compared in this tab, and the diff canvas is drawn locally. Nothing is sent to a server, and the page keeps no copy once you close or reload it. The PNG you download is encoded from the diff canvas at the union size, so a 1280 by 800 pair gives a 1280 by 800 file, with the grey wash included.
Frequently asked questions
Does it detect moved elements?
No. It compares each pixel with the pixel at the same position in the other image. A moved element appears twice, once where it was and once where it is now. The onion skin view shows that ghost most clearly.
Why is a change I can see not counted?
Either it fell under the threshold, which raises the allowed colour distance, or it was judged to be anti-aliasing and painted yellow. Lower the threshold, or tick the option that counts anti-aliased pixels as differences.