Skip to content

feat: add diff screenshot command for pixel-level image comparison#214

Open
dannyhw wants to merge 14 commits intocallstackincubator:mainfrom
dannyhw:dhw/charming-pascal
Open

feat: add diff screenshot command for pixel-level image comparison#214
dannyhw wants to merge 14 commits intocallstackincubator:mainfrom
dannyhw:dhw/charming-pascal

Conversation

@dannyhw
Copy link

@dannyhw dannyhw commented Mar 13, 2026

Uses pngjs to decode pngs and then compares each pixel with euclidean distance.
Mirrors the agent-browser CLI interface.

Usage:
agent-device diff screenshot --baseline before.png [--out diff.png] [--threshold 0.2]

try it out with

use scroll down for diff

node bin/agent-device.mjs open Settings --platform ios 
sleep 1
node bin/agent-device.mjs screenshot before.png 
node bin/agent-device.mjs scroll down 0.5
node bin/agent-device.mjs diff screenshot --baseline before.png --out diff.png

take two equal screenshots

node bin/agent-device.mjs open Settings --platform ios 
node bin/agent-device.mjs screenshot before.png 
node bin/agent-device.mjs diff screenshot --baseline before.png --out diff.png
image

Example diff
diff

Uses odiff-bin (SIMD-optimized) to compare the current device screenshot
against a baseline image, producing a visual diff output and mismatch
statistics. Mirrors the agent-browser CLI interface.

Usage:
  agent-device diff screenshot --baseline before.png [--out diff.png] [--threshold 0.2]
package.json Outdated
"dependencies": {
"@clack/prompts": "^1.0.0"
"@clack/prompts": "^1.0.0",
"odiff-bin": "^4.3.2"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

odiff is 22,5 MB, can we find a lighter alternative?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

replaced with a custom solution using just pngjs for decoding pngs

@dannyhw dannyhw marked this pull request as ready for review March 14, 2026 19:38
@dannyhw
Copy link
Author

dannyhw commented Mar 15, 2026

updated now to set the time to 9:41 before any screenshots so the time won't be a factor in diffs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants