Which diff algorithm is best for you?

Exact pixels, pixelmatch, Resemble.js, SSIM and a perceptual hash answer different questions. Pick by situation, compare them side by side, and see each one measured on the same example images.

Every visual regression tool has to decide whether two images are "the same". The algorithm behind that decision changes what your test suite notices and what it lets through: the same JPEG artifacts that fail one comparison are invisible to another. This page helps you choose, shows how the algorithms differ and, instead of asserting how they behave, measures them: five algorithms, eight example image pairs, every number computed by the engines of the image diff tool and committed with the page.

For the basics (color tolerance, anti-aliasing, the maximum diff ratio) read how image diffing works first; this page is about choosing between algorithms.

Pick by situation

Find your situation, then read the measured evidence below the table. Each card quotes the numbers from the examples further down.

  • Every pixel must match

    Exact pixels

    Nothing is tolerated, so nothing is missed and nothing needs explaining. It fits renders that are deterministic: generated images, or one machine and one browser build.

    Counts the one-letter typo (0.07% of the pixels), and also 4.30% for noise nobody can see.

  • Text renders slightly differently across machines

    pixelmatch

    It recognizes anti-aliased pixels and leaves them out, which is most of what font rasterizers disagree about. What is left still needs a maximum diff ratio, or a pinned renderer.

    Sub-pixel text shift: exact counts 2.60%, pixelmatch 0.66% (1.46% with anti-aliasing detection off).

  • A color must not drift, even slightly

    pixelmatch, low threshold

    Per-pixel comparisons see small color changes, and the tolerance decides: the exact comparison, pixelmatch with threshold 0 and Resemble.js with ignore nothing count them; the default threshold and the default tolerances let them through. SSIM works on brightness and the hash on a coarse grayscale, so neither sees them.

    A three-point color drift: pixelmatch at its default threshold counts 0%, with threshold 0 2.35%; SSIM reads 1.0000.

  • Images go through JPEG or another lossy step

    SSIM

    Compression noise is spread over the whole image at a low amplitude. A window-based structural score barely moves; a per-pixel exact comparison reports almost everything.

    JPEG at quality 60: exact flags 61.90% of the image, pixelmatch 1.80%, SSIM 0.9953.

  • You want one number a person can read

    SSIM

    A score between 0 and 1 is easy to chart and to put a limit on. Read it with the map of where the windows differ, not alone.

    An added cookie notice scores 0.9573, a clean copy 1. But a one-letter typo scores 0.9986: a mean hides small local changes.

  • Is it still the same picture? Sizes may differ

    Perceptual hash

    It keeps only the coarse structure, so it survives resizing and compression and says "different picture" for large changes. It cannot see small ones.

    Noise and JPEG: 0 / 64 bits differ. Added element: 18 / 64. Different heights: 26 / 64. A typo: 0 / 64.

  • Thousands of screenshots, speed matters

    Exact pixels or pixelmatch

    The pixel loops (exact, pixelmatch) and the hash are several times faster than Resemble.js and SSIM in these measurements. Native comparators exist for when even that is the slow part of the run.

    On a 960×600 page: exact 4.4 ms, pixelmatch 3.7 ms, pHash 8.8 ms, Resemble.js 24.8 ms, SSIM 44.1 ms (median of five runs, in a worker).

No algorithm wins everywhere. The usual answer is a pixel comparison with anti-aliasing detection and a small maximum diff ratio, in a pinned rendering environment (see why screenshots flake), and a second, structural check only where the pixel one is too noisy.

The five algorithms side by side

The first four rows describe what each algorithm does. The last row is a measurement: the median of five runs on a 960×600 page, executed in the tool's Web Worker in Chromium. Treat it as a ranking, not a benchmark: it depends on the machine, and Resemble.js's figure includes the library decoding the images itself.

 Exact pixelspixelmatchResemble.jsSSIMPerceptual hash
How it measures a differenceA pixel differs when any of its four channels (red, green, blue, alpha) differs by more than the tolerance, which is 0 by default.A perceptual color distance per pixel (OKLab in 8.0.0, YIQ in the older releases most tools bundle), compared with a threshold; pixels that look anti-aliased are detected and skipped.Per-channel differences against tolerances (a channel is similar when it differs by less than 16 by default) and brightness bounds, with presets that also detect anti-aliasing or compare brightness only.Structural similarity: luminance, contrast and structure compared over sliding windows (11 by 11 by default) of the grayscale images, averaged.Each image is reduced to 32 by 32 gray values, a discrete cosine transform keeps the 8 by 8 lowest frequencies, and each becomes one bit against the median: a 64-bit fingerprint. The median includes the lowest coefficient, the average brightness, so a uniform brightness shift leaves the hash unchanged.
What it returnsA count of differing pixels, and a diff image.A count of mismatched pixels, and a diff image; with windowSize the highest count in any sliding window instead.A mismatch percentage, whether the sizes match, the bounding box of the differences, and a diff image.A mean score from 0 to 1 (1 is identical), and a map with a score per window.The Hamming distance between the two fingerprints, 0 to 64.
Tolerance knobsA per-channel tolerance.threshold (0 to 1, default 0.1), includeAA, an ignore mask, the window size; the limit on the count is yours.The ignore presets (nothing, less, antialiasing, colors, alpha), the output style, scaling to the same size, ignored boxes.The window size, the implementation variant, downsampling; the limit on the score is yours.The size of the kept square (8 gives 64 bits, 16 gives 256); the limit on the distance is yours.
StrengthsNothing slips through, easy to explain.Small, fast, anti-aliasing aware, a color threshold that follows what eyes notice.Presets that work without tuning, tolerates different sizes, reports where the changes are.Tolerates compression and noise, one readable score, the map shows where.Survives resizing, compression and small shifts, compares images of different sizes, fingerprints are tiny.
WeaknessesCounts rendering noise and compression artifacts as changes; no notion of what a person can see.A threshold means something different in each release and color space; a count says how many pixels, not how much they matter; images must have the same size.The presets are blunt (the antialiasing one also raises the tolerance to 32 per channel), slower than the pixel loops above in these measurements.Blind to color changes at equal brightness, a mean hides small local changes, slower, and the default downsampling blurs one-pixel details.Blind to small changes and to global brightness and color; it says "same picture", not "pixel-perfect". This implementation is its own variant, not bit-identical to other libraries.
Typical useDeterministic renders: generated images, one machine and one browser build.The comparator behind most JavaScript test tools.BackstopJS builds on a Node fork of it.Perceptual quality checks; jest-image-snapshot offers it as its second comparison method.Near-duplicate detection and coarse "did the page change at all" checks.
Speed, 960×600 (measured) 4.4 ms3.7 ms24.8 ms44.1 ms8.8 ms

The numbers an algorithm returns live on different scales, so a table of results is not a ranking of algorithms: 0.66% from pixelmatch, 0.9938 from SSIM and 0 / 64 from the hash all describe the same pair of images.

Measured examples

Eight pairs, each made by rendering a small web page in Chromium and changing one thing about it. Every cell below is what an algorithm returned with its defaults, plus the variants that explain the differences: pixelmatch with anti-aliasing detection off (includeAA) and with threshold 0, and Resemble.js with ignore set to nothing and to antialiasing. Cells are shaded by how large the difference is on the algorithm's own scale: green for none, amber for small, red for large. The last column of the first block is a judgement, not a measurement: whether most teams would want a test to fail for it.

ExampleWorth failing a test?Exactpixelmatchpixelmatch, includeAApixelmatch, threshold 0Resemble.jsResemble.js, ignore nothingResemble.js, ignore antialiasingSSIMpHash
Text shifted by a sub-pixelno2.60%0.66%1.46%1.08%1.81%2.60%0.34%0.99380 / 64
Everything moved by 1 pxusually not4.54%1.71%2.82%2.76%3.80%4.54%2.11%0.95272 / 64
Slight color tintyes2.43%0%0%2.35%0.00%2.43%0.00%1.00000 / 64
JPEG compression artifactsno61.90%1.80%1.89%58.52%9.51%61.90%0.00%0.99530 / 64
An element was addedyes3.05%2.87%2.97%2.91%2.99%3.05%2.94%0.957318 / 64
Different image sizesyes26.76%21.41%22.05%25.93%22.31%26.76%21.65%0.809726 / 64
Scattered noiseno4.30%0%0%3.53%0.00%4.30%0.00%0.99990 / 64
One letter changedyes0.07%0.02%0.06%0.02%0.06%0.07%0.05%0.99860 / 64

Each example below shows the two images, the diff each algorithm drew, and a link that opens the pair in the tool, where you can change the options and see the result.

Text shifted by a sub-pixel

The content of the page moved 0.3 px to the right. Boxes snap back to the same pixels, but every glyph is rasterized at a new sub-pixel offset: rendering noise, not a change anyone sees.

Baseline of the example: Text shifted by a sub-pixel
baseline 960×600
Actual image of the example: Text shifted by a sub-pixel
actual 960×600
  • Diff drawn by Exact pixels

    Exact pixels

    2.60%

    15,004 px

  • Diff drawn by pixelmatch

    pixelmatch

    0.66%

    3,812 px

  • Diff drawn by Resemble.js

    Resemble.js

    1.81%

    10,430 px

  • Diff drawn by SSIM

    SSIM

    0.9938

  • Diff drawn by Perceptual hash

    Perceptual hash

    0 / 64

Open this pair in the image diff tool

Everything moved by 1 px

The main column moved one pixel to the right. Every edge and every glyph in it is in a new place, but the page looks the same.

Baseline of the example: Everything moved by 1 px
baseline 960×600
Actual image of the example: Everything moved by 1 px
actual 960×600
  • Diff drawn by Exact pixels

    Exact pixels

    4.54%

    26,131 px

  • Diff drawn by pixelmatch

    pixelmatch

    1.71%

    9,828 px

  • Diff drawn by Resemble.js

    Resemble.js

    3.80%

    21,879 px

  • Diff drawn by SSIM

    SSIM

    0.9527

  • Diff drawn by Perceptual hash

    Perceptual hash

    2 / 64

Open this pair in the image diff tool

Slight color tint

The primary button and the selected payment method drifted by three RGB points per channel (#4f46e5 to #4c49e2), the trace a changed design token leaves.

Baseline of the example: Slight color tint
baseline 960×600
Actual image of the example: Slight color tint
actual 960×600
  • Diff drawn by Exact pixels

    Exact pixels

    2.43%

    13,986 px

  • Diff drawn by pixelmatch

    pixelmatch

    0%

    0 px

  • Diff drawn by Resemble.js

    Resemble.js

    0.00%

    0 px

  • Diff drawn by SSIM

    SSIM

    1.0000

  • Diff drawn by Perceptual hash

    Perceptual hash

    0 / 64

Open this pair in the image diff tool

JPEG compression artifacts

The same page, saved as a JPEG at quality 60 and read back. Nothing changed, but almost no pixel survives the codec untouched.

Baseline of the example: JPEG compression artifacts
baseline 640×420
Actual image of the example: JPEG compression artifacts
actual 640×420
  • Diff drawn by Exact pixels

    Exact pixels

    61.90%

    166,377 px

  • Diff drawn by pixelmatch

    pixelmatch

    1.80%

    4,832 px

  • Diff drawn by Resemble.js

    Resemble.js

    9.51%

    25,573 px

  • Diff drawn by SSIM

    SSIM

    0.9953

  • Diff drawn by Perceptual hash

    Perceptual hash

    0 / 64

Open this pair in the image diff tool

An element was added

A cookie notice (240 by 80 px, bottom right) appeared over the page. A real, visible regression that covers about 3% of the image.

Baseline of the example: An element was added
baseline 960×600
Actual image of the example: An element was added
actual 960×600
  • Diff drawn by Exact pixels

    Exact pixels

    3.05%

    17,552 px

  • Diff drawn by pixelmatch

    pixelmatch

    2.87%

    16,513 px

  • Diff drawn by Resemble.js

    Resemble.js

    2.99%

    17,229 px

  • Diff drawn by SSIM

    SSIM

    0.9573

  • Diff drawn by Perceptual hash

    Perceptual hash

    18 / 64

Open this pair in the image diff tool

Different image sizes

A settings section is gone, so everything below it moved up and the full-page screenshot got shorter: the two images have different heights.

Baseline of the example: Different image sizes
baseline 960×1286
Actual image of the example: Different image sizes
actual 960×1021
  • Diff drawn by Exact pixels

    Exact pixels

    26.76%

    330,355 px

  • Diff drawn by pixelmatch

    pixelmatch

    21.41%

    264,342 px

  • Diff drawn by Resemble.js

    Resemble.js

    22.31%

    275,427 px

  • Diff drawn by SSIM

    SSIM

    0.8097

  • Diff drawn by Perceptual hash

    Perceptual hash

    26 / 64

Open this pair in the image diff tool

Scattered noise

One pixel in twenty differs by up to 2 levels per channel (a seeded generator), the way GPU dithering or a lossy capture scatters stray pixels. Invisible to the eye.

Baseline of the example: Scattered noise
baseline 960×600
Actual image of the example: Scattered noise
actual 960×600
  • Diff drawn by Exact pixels

    Exact pixels

    4.30%

    24,782 px

  • Diff drawn by pixelmatch

    pixelmatch

    0%

    0 px

  • Diff drawn by Resemble.js

    Resemble.js

    0.00%

    0 px

  • Diff drawn by SSIM

    SSIM

    0.9999

  • Diff drawn by Perceptual hash

    Perceptual hash

    0 / 64

Open this pair in the image diff tool

One letter changed

The page heading says "Overwiew" instead of "Overview": a real regression a few dozen pixels big.

Baseline of the example: One letter changed
baseline 960×600
Actual image of the example: One letter changed
actual 960×600
  • Diff drawn by Exact pixels

    Exact pixels

    0.07%

    402 px

  • Diff drawn by pixelmatch

    pixelmatch

    0.02%

    119 px

  • Diff drawn by Resemble.js

    Resemble.js

    0.06%

    347 px

  • Diff drawn by SSIM

    SSIM

    0.9986

  • Diff drawn by Perceptual hash

    Perceptual hash

    0 / 64

Open this pair in the image diff tool

What the numbers say

A tolerance, not the algorithm class, separates strict from forgiving. The exact comparison counts 2.60% of the pixels on the sub-pixel text shift, 4.30% on the noise and 61.90% on the JPEG. pixelmatch at its default threshold counts 0.66%, 0% and 1.80%. Set its threshold to 0 and it counts 3.53% and 58.52% again. Resemble.js behaves the same way: its default tolerances give 9.51% on the JPEG, ignore: nothing gives 61.90%.

Anti-aliasing detection removes a little over half of the text noise, not all of it. On the sub-pixel text shift pixelmatch counts 1.46% with detection off and 0.66% with it on. The rest is a different problem; a pinned renderer removes it at the source.

Tolerance hides subtle color drift. The tint of three RGB points is counted as 2.43% by the exact comparison and as 2.35% by pixelmatch at threshold 0, but as 0% at the default threshold and 0.00% by Resemble.js's default. SSIM reads 1.0000: it works on brightness, so a color change at equal brightness does not register. If a design token must not drift, lower the threshold.

A small real change can be smaller than harmless noise. The one-letter typo is 0.02% of the pixels for pixelmatch, less than the sub-pixel text shift (0.66%) and the JPEG (1.80%). A maximum diff ratio that lets the JPEG through lets the typo through too. SSIM, with 0.9986, scores it better than the harmless 1 px shift (0.9527); the hash sees nothing at all (0 / 64). Changing the algorithm does not fix this: masks over the regions that change, a limit per region, or a renderer that does not produce the noise do.

Nothing here forgives a shift. One pixel of movement counts 1.71% for pixelmatch, 3.80% for Resemble.js and drops SSIM to 0.9527, about where the added cookie notice puts it (0.9573). These algorithms compare position by position, so fixing the layout instability is the way, or the blink view of the tool to see what moved.

The hash separates structure from noise, at the price of small changes. It reads 0 / 64 on the noise and 0 / 64 on the JPEG, 18 / 64 on the added element and 26 / 64 on the images of different heights. pixelmatch at its defaults also ignores the noise (0%) and SSIM stays at 0.9999, so noise alone does not set the hash apart. What does is that it needs no tolerance to tell the large changes from the rest. The price is the typo and the 1 px shift (2 / 64), which it cannot resolve, and any global brightness or color change: the median includes the average-brightness coefficient, so a uniform shift leaves the hash unchanged (the color tint reads 0 / 64).

Different sizes are handled differently by every tool, and by the algorithms. pixelmatch refuses them outright. The tool pads the smaller image first (magenta by default, or transparent), so the padding counts as a difference: 26.76% for the exact comparison, 21.41% for pixelmatch and 26 / 64 for the hash. Resemble.js reports isSameDimensions: false and compares the two on the larger canvas itself.

Speed. On the 960×600 page the exact comparison takes 4.4 ms, pixelmatch 3.7 ms, the hash 8.8 ms, Resemble.js 24.8 ms and SSIM 44.1 ms. The SSIM figure is for the library's default downsampling: it shrinks images whose smaller side is over 256 px before comparing, which makes it faster and blurs one-pixel details. Turn the downsampling off in the tool to compare every pixel.

Which tools use which

What each tool does underneath, read from the packages' own source and metadata on 2026-11-07 (versions in the first column). A tool that is not here either is not documented at this depth or does its comparison on a server; the comparison lists what each one documents.

ToolComparisonDifferent sizes
pixsame (@pixsame/cypress-plugin-visual-regression-diff 1.0.0)pixelmatch 7.2.0 (YIQ color distance). Options reach pixelmatch through diffConfig; by default anti-aliased pixels count (includeAA: true). maxDiffThreshold is a share of the pixels, 0.01 by default.Pads to the larger size and adds a warning
Playwright toHaveScreenshot (1.64.1 and 1.65.0)A copy of pixelmatch (YIQ) inside Playwright; threshold 0.2 by default, maxDiffPixels and maxDiffPixelRatio for the limit. An optional comparator: 'ssim-cie94' uses a CIE94 color distance and SSIM only to recognize anti-aliasing.Pads to the larger size and fails with the two sizes in the message
jest-image-snapshot (6.5.2)pixelmatch ^5.1.0 (YIQ), or ssim.js ^3.1.1 with comparisonMethod: 'ssim'.
Vitest toMatchScreenshot (5.1.0)A comparator named pixelmatch, implemented with @blazediff/core in this release; limits allowedMismatchedPixels and allowedMismatchedPixelRatio.Fails at once, without a diff
cypress-visual-regression (6.0.1)pixelmatch 7.2.0.
cypress-image-diff-js (2.8.0)pixelmatch ^5.1.0.
BackstopJS (6.3.25)Resemble.js analysis through a Node fork (@mirzazeyrek/node-resemble-js). misMatchThreshold is a percentage, 0.1 by default.requireSameDimensions decides whether a size change fails
lost-pixel (3.22.0)pixelmatch 5.3.0 and odiff-bin 2.6.1 are both dependencies.

Which pixelmatch release a tool bundles matters: releases up to 7.2.0 measure color in YIQ, 8.0.0 in OKLab. The same threshold number is therefore not the same tolerance in pixsame or Playwright and in the tool on this site, and the counts in the examples above will not match those tools to the pixel. They show how the algorithm family behaves, not what a given tool reports.

Other approaches

These are not in the image diff tool, because they have no browser build or are not the same kind of algorithm. Everything here is from the projects' own documentation and metadata; the speed claims are theirs and were not measured for this page.

  • odiff is a native comparator, written in Zig with SIMD optimizations (originally OCaml), with a Node binding and a server mode. It uses the YIQ NTSC color space and offers threshold, antialiasing and ignored regions. Its README says Argos uses it, and lost-pixel lists it as a dependency.
  • looks-same compares colors with CIEDE2000. Its default tolerance is 2.3, described as the just noticeable difference; it ignores anti-aliasing and the text caret by default, and strict: true turns the tolerance off.
  • @blazediff/core describes itself as pixel-by-pixel comparison with block-based optimization, "1.5x times faster than pixelmatch". Vitest 5.1.0 uses it for its pixelmatch comparator.
  • Hosted services (Percy, Applitools, Chromatic and others) compare on their servers with their own algorithms; what they document is in the comparison.

How the examples were made

The pages, the images and the numbers are generated by one script, apps/site/scripts/make-diff-examples.mjs. It renders fixtures with Chromium, bundles the very Web Worker the image diff tool runs (decoding, padding, all five engines), runs it in Chromium on every pair, and writes the images to public/diff-examples/ and the measurements to data/diff-examples.json. This page reads that file; there is no number on it that was typed by hand. Run pnpm --filter @visual-regression/site diff-examples to reproduce them. The fixtures use the system fonts of the machine that renders them, so a rerun elsewhere can move the pixel counts by a few pixels and records another Chromium version; the orderings the prose relies on are asserted by the site's unit tests.

What the numbers are not:

  • One fixture application (a dashboard, a checkout, a blog page and a settings page, all in Chromium) and eight changes made on purpose. Real suites have more variety.
  • Each algorithm at its library defaults, plus the few variants named above. Every one can be tuned, and a tuned algorithm can behave differently.
  • The versions in use: pixelmatch 8.0.0, resemblejs 5.0.0 and ssim.js 3.5.0, measured in Chromium 156.0.8078.4. The hash is this tool's own implementation of the pHash family and is not bit-identical with other libraries.
  • Timings are medians of five runs on one machine.
  • Pixel counts depend on the fonts of the machine that rendered the fixtures (see above).

Try it yourself

Open any example in the image diff tool, or drop two of your own screenshots: nothing is uploaded. Change an algorithm's options and watch the number move; that is the quickest way to find out what your own pages need.