Repository navigation
refactor: skip ignored regions with pixelmatch's ignoreMask - #1301
Merged
plum117 merged 2 commits intoOct 9, 2026
Merged
Conversation
pixelmatch 8 can skip pixels with an ignoreMask (one byte per pixel). compareImages now builds that mask from the ignored boxes (clamped to the image) instead of painting the boxes black in both images. The files on disk and the green regions of the diff image do not change. The pixels next to an ignored box keep their real neighbours for the anti-aliasing detection. With AA forgiven this can change the count a little at the box edges (+15 of 61 208 pixels on a real pair); with the default settings the counts on the real pairs did not change. Tests: the mocked test checks the mask and that the images are not changed; new tests run the real pixelmatch with ignored boxes (a difference inside a box does not count, outside it does, a box larger than the image is clamped). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
🦋 Changeset detectedLatest commit: 76a2cf2 The changes in this PR will be included in the next version bump. This PR includes changesets to release 2 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
plum117
marked this pull request as ready for review
October 9, 2026 10:22
|
The test passed when an ignored pixel of an image was set to 0, and it did not check the second image. Use 2 small images with a different value in each channel and compare both images and the mask with the expected values. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Uses pixelmatch 8's new
ignoreMaskoption for the ignored regions (ignored elements and block-outs), instead of painting those regions black in both images before the comparison.What changes for users
processDiffPixels).Measured with pixelmatch 8 on real image pairs, with ignored boxes over changed areas:
ignoreAntialiasing(0.13, AA forgiven): black / maskSo the counts change only a little, and only with anti-aliasing forgiven, at the edges of ignored regions. Patch changeset with that note.
Changes
compareImages.ts:createIgnoreMask()builds one byte per pixel (1 inside a box, clamped to the image size) and passes it asignoreMask;zeroIgnoredBoxes()is removed.compareImages.test.ts: the mocked test checks the mask and that the images are not changed; a test checks that no mask is passed without ignored boxes.compareImages.ignoredBoxes.test.tswith the real pixelmatch: a difference inside a box does not count, a difference outside it counts (exactly the 4 pixels of a 2×2 square), and a box larger than the image is clamped.Test
pnpm test(lint, types, 1083 unit tests): pass.test.local.chrome.v10,.jasmine,test.local.desktop.multi,test.local.desktop(setup run, then the real run; includes the ignore-region checks): pass.scheduled-testswithrefs/pull/<number>/headafter reviewing the commit.Not in this PR:
windowSizepixelmatch 8 also has
windowSize(the largest number of different pixels in any N×N square instead of the total). That would be a new user-facing compare mode and needs a design first (option name, how the result and the threshold are reported, docs).🤖 Generated with Claude Code