odiff-image-diffing
БесплатноБез исполняемых скриптовНе проверенodiff pixel-by-pixel image diffing. Use when comparing screenshots, detecting visual regressions, diffing before/after PNGs, asserting golden images.
от laurigates★ 61 звезда на GitHubОб этом скилле
odiff Image Diffing
odiff is a native, SIMD-accelerated, pixel-by-pixel image comparator. It is the fastest popular image-diff tool in its class (~10-100x faster than pixelmatch / resemble.js), supports PNG/JPEG/WebP/TIFF/BMP, writes a diff artifact to disk, and exits with structured codes that make it CI-friendly.
When to Use This Skill
| Use this skill when... | Use another skill instead when... |
|---|---|
| Comparing two PNG/JPEG screenshots on disk | Asserting Playwright snapshots in a test suite (use playwright-testing) |
| Detecting visual regressions between before/after renders | Configuring a Playwright snapshot workflow from scratch (use configure-ux-testing) |
| Diffing rendered output against a golden file | Transforming, resizing, or converting images (use imagemagick-conversion) |
| Validating that a CSS or template change is visually neutral | Generating a new image from a prompt (use generate-image) |
| Failing CI on pixel drift with a machine-readable exit code | Producing the screenshot itself (use playwright-cli) |
Installation
# Recommended: npm package ships the native binary
npm install -g odiff-bin
# Project-local
npm install --save-dev odiff-bin
# Verify
odiff --version
The npm package is odiff-bin; the installed command is odiff. Native binaries are also available from GitHub Releases for sandboxes without npm registry access.
Core Usage
odiff <base_image> <comp_image> [diff_output] [options]
base_imageandcomp_imageare the two images to compare. Any of PNG, JPEG, WebP, TIFF, BMP. Cross-format compares are fine.diff_outputis an optional PNG path. When supplied, odiff writes a visual diff highlighting the changed pixels in#cd2cc9magenta.- Exit code carries the verdict — read it instead of parsing prose stdout.
odiff before.png after.png diff.png
Exit Codes
odiff is exit-code-first by design. Branch on the exit code, not on stdout text:
| Code | Meaning |
|---|---|
0 |
Images match within threshold |
21 |
Layout difference (only when --fail-on-layout is set; otherwise treated as pixel diff) |
22 |
Pixel differences found |
1 |
Usage / file error (e.g. base image could not be loaded) |
CI pattern:
if odiff before.png after.png diff.png --parsable-stdout; then
echo "visual match"
else
code=$?
echo "visual drift (exit $code) — see diff.png"
exit $code
fi
Machine-Readable Output
--parsable-stdout swaps the human report for a single line that's trivial to parse:
| Result | stdout |
|---|---|
| Match | 0 |
| Pixel diff | <changed_pixels>;<percentage> (e.g. 1681;16.81) |
Layout diff (with --fail-on-layout) |
layout |
Pair with the exit code for a complete verdict; the line itself is the metric to log or post as a CI annotation.
Composition Recipes
1. Before/After diff with playwright-cli
playwright-cli saves PNG screenshots to .playwright-cli/. Pair the two ends of a change with odiff to confirm the visual delta is what you expected.
# Baseline
playwright-cli goto https://app.example.com/dashboard
playwright-cli screenshot --filename=baseline.png
# Make the code change, then re-screenshot
playwright-cli goto https://app.example.com/dashboard
playwright-cli screenshot --filename=current.png
# Diff — exit 0 = visually unchanged, exit 22 = drift
odiff .playwright-cli/baseline.png .playwright-cli/current.png \
.playwright-cli/diff.png --parsable-stdout --antialiasing
--antialiasing ignores antialiased pixels, which suppresses noise from font-rendering jitter across runs.
2. Batch directory compare
For a baseline directory (golden files) and a current directory (fresh renders), iterate matched filenames:
baseline_dir=tests/__snapshots__
current_dir=tests/__current__
mkdir -p tests/__diff__
fail=0
for img in "$baseline_dir"/*.png; do
name=$(basename "$img")
current="$current_dir/$name"
diff="tests/__diff__/$name"
if odiff "$img" "$current" "$diff" --parsable-stdout --antialiasing; then
echo "OK $name"
else
echo "DRIFT $name"
fail=1
fi
done
exit $fail
3. CI exit-code pattern with layout protection
Treat layout changes as a distinct failure mode from pixel drift — a layout shift usually wants human attention, while a pixel diff may be tolerable under a small threshold.
odiff before.png after.png diff.png \
--fail-on-layout \
--threshold 0.05 \
--antialiasing \
--parsable-stdout
case $? in
0) echo "::notice::visual unchanged" ;;
21) echo "::error::layout shifted — review diff.png"; exit 1 ;;
22) echo "::warning::pixel drift — review diff.png"; exit 1 ;;
*) echo "::error::odiff failure"; exit 1 ;;
esac
Advanced Options
| Flag | When to use |
|---|
Установить odiff-image-diffing в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Bash(odiff *)ReadGlobTodoWriteFAQ
Что делает скилл odiff-image-diffing?
odiff pixel-by-pixel image diffing. Use when comparing screenshots, detecting visual regressions, diffing before/after PNGs, asserting golden images.
Как установить скилл odiff-image-diffing?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл odiff-image-diffing запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
theme-factory
Toolkit for styling artifacts with a theme. These artifacts can be slides, docs, reportings, HTML landing pages, etc. There are 10 pre-set themes with…
от Anthropicaccess
Manage Discord channel access — approve pairings, edit allowlists, set DM/group policy. Use when the user asks to pair, approve someone, check who's allowed…
от Anthropicconfigure
Set up the Discord channel — save the bot token and review access policy. Use when the user pastes a Discord bot token, asks to configure Discord, asks "how…
от Anthropicaccess
Manage iMessage channel access — approve pairings, edit allowlists, set DM/group policy. Use when the user asks to pair, approve someone, check who's allowed…
от Anthropic