pixel-diff
Perceptual RGBA image diffing: YIQ pixelmatch, anti-aliasing, SSIM, ignore masks and change clusters.
A standalone, dependency-free engine for deterministic comparison of two RGBA8
screenshots. It sits in layer L0: no a11y-* dependency, no browser, no file
system.
Status
New, not yet released. Consumers are the visual-evidence and visual-audit packages and the auditors built on them.
What the package does
- Pixel metric: YIQ colour delta against
35215 * threshold^2, alpha blended against white, so fully transparent pixels with different RGB do not differ. Anti-aliased edge pixels (3x3 neighbourhood,has_many_siblings) are counted separately inaa_pixelsunlessinclude_aais set. Independent implementation of the pixelmatch algorithm. - SSIM: mean over 8x8 luminance windows at stride 4, constants
C1 = 6.5025,C2 = 58.5225; identical images give exactly1.0. - Ignore masks:
ignore_regionsare excluded and reported asignored_pixels;diff_ratiorelates to the remaining pixels. - Clusters:
cluster_distancemerges changed pixels via a grid (cell sizemax(d, 1), touching cells merge) and union-find, iterative and sorted byy, thenx. Bounds are exact pixel bounds. - Diff image: optional, with configurable colours for differences, anti-aliasing and masked pixels over a dimmed original.
Features
png:png_codecwithdecode_png,decode_png_with_limit(default 64 MiB) andencode_png; all colour types are converted to RGBA8.serde: derives forPixelRect,DiffOptions,DiffResult,RgbaImage.
What the package does not do
No file or network I/O, no CLI, no accessibility vocabulary, no a11y-report
findings, no own PNG/DEFLATE implementation. Images of different size are an
error, not resized.