feat(image): add image diff command (ImageMagick compare equivalent) #18
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "feat/image-diff"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
New subcommand:
monkey image diff <A> <B> <OUT>. Pixel-level comparison modelled after ImageMagickcompare/pixelmatch.The flag surface is two orthogonal axes:
--bgfills pixels where A and B match.a/boverlay the diff on top of one of the originals;transparentproduces RGBA output.--highlightpaints pixels where A and B differ.rgbemits per-channel|A - B|(the classic IM difference look); the colour names paint a solid block;a/bpass through the original pixel from either side.--thresholdis per-channel: a pixel counts as a match whenmax(|dr|, |dg|, |db|, |da|) <= threshold * 255.Validation
--bg transparentrequires a.pngoutput; non-PNG sinks fail fast.image::savewrites.Tests
Five unit tests in
src/image/diff.rscover dimension mismatch, transparent-+-non-PNG rejection, matched-pixel background, highlight painting, and threshold suppression (44 total tests passing, 2 ignored).End-to-end smoke test against magick-generated 60x40 inputs:
image diff a.png b.png out.png-> rgb mode, black bg, changed pixel reads(223,223,159)(≈ white minus the#202060background that disappeared).image diff --bg a --highlight red a.png b.png out.png-> changed pixel is pure red(255,0,0).image diff --bg transparent --highlight red ... out.png-> matched pixels have alpha 0.--bg transparent ... out.jpg-> errors with "requires a .png output".Local
cargo fmt --check,cargo clippy --all-targets -- -D warnings,cargo build --all-targets,cargo testall pass.Test plan
Checkworkflow passes for this branch.image diffagainst two screenshots (one with a small UI change) and visually confirm the diff highlights the change.image diff --bg a --highlight red old.png new.png overlay.pngand confirm the result looks like ImageMagickcompare.image diffcommand (ImageMagick compare equivalent)