Pixel-level screenshot comparison using the pixelmatch algorithm. Runs inside Playwright's Canvas API — no AWT/ImageIO dependency, GraalVM native-image safe.
Based on pixelmatch by Mapbox (ISC license): https://github.com/mapbox/pixelmatch
Pixel-level screenshot comparison using the pixelmatch algorithm. Runs inside Playwright's Canvas API — no AWT/ImageIO dependency, GraalVM native-image safe. Based on pixelmatch by Mapbox (ISC license): https://github.com/mapbox/pixelmatch
(compare-screenshot-files baseline-path current-path & opts)Compare two PNG screenshot files. See compare-screenshots for options.
Compare two PNG screenshot files. See compare-screenshots for options.
(compare-screenshots baseline
current
&
{:keys [threshold include-aa alpha diff-path]
:or {threshold 0.1 include-aa false alpha 0.1}})Compare two PNG screenshots pixel-by-pixel using the pixelmatch algorithm (YIQ NTSC color space with anti-aliasing detection).
Runs the comparison inside Playwright's Canvas API — no AWT/ImageIO, GraalVM native-image safe.
baseline and current are PNG byte arrays (as returned by page/screenshot).
Options: :threshold — matching threshold 0.0-1.0 (default 0.1, lower = stricter) :include-aa — count anti-aliased pixels as diff (default false) :alpha — opacity of original image in diff (default 0.1) :diff-path — optional path to save the diff image PNG
Returns: {:matched true/false :diff-count number of different pixels :total-pixels total pixel count :diff-percent percentage of different pixels (2 decimal places) :width comparison width :height comparison height :diff-image diff PNG as byte[] :baseline-dimensions {:width w :height h} :current-dimensions {:width w :height h} :dimension-mismatch true/false}
Compare two PNG screenshots pixel-by-pixel using the pixelmatch algorithm
(YIQ NTSC color space with anti-aliasing detection).
Runs the comparison inside Playwright's Canvas API — no AWT/ImageIO,
GraalVM native-image safe.
`baseline` and `current` are PNG byte arrays (as returned by page/screenshot).
Options:
:threshold — matching threshold 0.0-1.0 (default 0.1, lower = stricter)
:include-aa — count anti-aliased pixels as diff (default false)
:alpha — opacity of original image in diff (default 0.1)
:diff-path — optional path to save the diff image PNG
Returns:
{:matched true/false
:diff-count number of different pixels
:total-pixels total pixel count
:diff-percent percentage of different pixels (2 decimal places)
:width comparison width
:height comparison height
:diff-image diff PNG as byte[]
:baseline-dimensions {:width w :height h}
:current-dimensions {:width w :height h}
:dimension-mismatch true/false}cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |