Repository navigation
feat: compare images with pixelmatch 8 - #42
Merged
Merged
Conversation
pixelmatch 8.0.0 replaces its colour-difference metric (YIQ) with OKLab and HyAB. The API and the scale of `threshold` are unchanged, but the number of pixels counted as different is not, so `toEqualImageData` and the fixtures built on it can report different counts under the same `threshold` and `tolerance`. The shift is largest for anti-aliased edges and semi-transparent pixels. A reference image that matches pixel for pixel still counts 0 under both metrics. A fixture that sat close to its `tolerance` may start failing, or stop failing; re-render it and regenerate its reference image, or adjust that fixture's `threshold` / `tolerance`. The matcher still blends transparency against white unless a fixture passes `checkerboard: true`.
|
🎉 This PR is included in version 1.1.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
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.
Moves the image comparison to pixelmatch 8.0.0 (
^7.2.0->^8.0.0). The lockfile diff is thepixelmatchentry only.pixelmatch 8.0.0 release notes
What changes for consumers
pixelmatch 8 replaces its colour-difference metric (YIQ) with OKLab + HyAB. The API and the scale of
thresholdare unchanged, but the number of pixels counted as different changes.toEqualImageDataandcreateFixturespassthresholdandtolerancestraight through, so the same fixtures can report different counts under the same limits.tolerancecan move either way, mostly around anti-aliased edges and semi-transparent pixels.saveFixtureImage/fixtures:update) or adjust that fixture'sthreshold/toleranceto the new measurement. Do not raise a global default.feat:(minor) and notfix(deps):: it changes numbers that consumers' tests assert on. Squash-merging with this title makes semantic-release cut a minor release.Not changed: the matcher still blends transparency against plain white (
checkerboard: false) unless a fixture passescheckerboard: true; pixelmatch 7.2 and 8 both default it totrue.Measurements from this repo's own suite
npm teston this branch (lint, typecheck, type tests, 9 unit tests, browser suite in Chromium and Firefox), before and after the bump:The 2 skips are the "unsupported browser features" spec, which skips by design where OffscreenCanvas is missing. I logged the count
toEqualImageDatacomputes for each fixture (limit = 0.1% of 65536 px = 65 px, threshold 0.1):All counts are 0 because the renders are pixel-identical to the references, so the suite here does not exercise the metric and nothing in it needed regenerating or adjusting. To show that the metrics do differ, I compared
bar.pngwithline-sprited.png(two unrelated images, only a probe) withcheckerboard: false:and with
checkerboard: true: