Skip to content

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

Merged
thymikee merged 7 commits intocallstackincubator:mainfrom
dannyhw:dhw/charming-pascal
Mar 17, 2026
Merged

feat: add diff screenshot command for pixel-level image comparison#214
thymikee merged 7 commits intocallstackincubator:mainfrom
dannyhw:dhw/charming-pascal

Conversation

@dannyhw
Copy link
Contributor

@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

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
Contributor 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
Contributor 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

@thymikee thymikee force-pushed the dhw/charming-pascal branch from 721c0d0 to 416f424 Compare March 17, 2026 17:05
@thymikee thymikee force-pushed the dhw/charming-pascal branch from ed6e1ed to 2de9379 Compare March 17, 2026 17:19
Copy link
Contributor

@thymikee thymikee left a comment

Choose a reason for hiding this comment

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

Thank you! This is pretty cool :D

Android diff iOS diff
Image Image

@thymikee thymikee merged commit 3f9eee0 into callstackincubator:main Mar 17, 2026
6 of 7 checks passed
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