Skip to content

v8.0.0

Latest

Choose a tag to compare

@mourner mourner released this 06 Oct 09:14
· 1 commit to main since this release

A major update: a new, much more accurate color difference metric (replacing the one used since 2015), and two new options for handling noise and irrelevant regions in tests.

馃幆 New color difference metric

Colors are now compared using the OKLab color space and the HyAB distance instead of YIQ. It's much closer to how people perceive color differences, so you get fewer false positives and fewer missed changes (#127). The math is more involved, but it's heavily optimized, so pixelmatch runs nearly as fast as before.

馃獰 windowSize option

Returns the largest number of differing pixels in any N脳N square instead of the total count. Scattered noise like GPU dithering or font anti-aliasing stays low, while real changes, which are usually compact, stand out:

if (pixelmatch(img1, img2, null, width, height, {windowSize: 16}) > 28) throw new Error('changed');

馃檲 ignoreMask option

A per-pixel mask of areas to skip, like timestamps or animations. (#171 by @Venefilyn, closes #163)

Other improvements

  • More reliable anti-aliasing detection on images with transparency.
  • Colors that differ only in transparency are much less likely to be missed.

鈿狅笍 Upgrading from v7

The API is unchanged, and threshold keeps its scale (0 to 1, where 1 is black vs. white) and 0.1 default. But diff counts will differ because of the new metric. If your tests rely on exact counts or a tuned threshold, re-check them.