This guide covers the command-line interface (CLI) for auto-image-diff, including all commands, options, and usage patterns.
npm install -g auto-image-diffAfter installation, you can use either auto-image-diff or the shorter alias aid.
Performs alignment and diff generation in one command.
aid compare <reference> <target> <output-dir> [options]Arguments:
reference- Path to the reference/baseline imagetarget- Path to the target/comparison imageoutput-dir- Directory for output files
Options:
-t, --threshold <percent>- Difference threshold (default: 0.1)-c, --color <color>- Highlight color for differences (default: "red")-e, --exclude <file>- Path to exclusions.json file-s, --smart- Enable smart classification
Example:
aid compare baseline.png current.png results/ -t 0.5 -sAligns two images using various methods.
aid align <reference> <target> <output> [options]Options:
-m, --method <method>- Alignment method: subimage, phase, or feature (default: "subimage")
Examples:
# Default subimage alignment
aid align ref.png target.png aligned.png
# Phase correlation alignment
aid align ref.png target.png aligned.png -m phase
# Feature-based alignment (requires OpenCV)
aid align ref.png target.png aligned.png -m featureCreates a visual diff between two images.
aid diff <image1> <image2> <output> [options]Options:
-c, --color <color>- Highlight color (default: "red")--no-lowlight- Disable lowlighting of unchanged areas-e, --exclude <file>- Exclusions file path-s, --smart- Enable smart classification--smart-diff- Generate detailed smart diff report-f, --focus <types>- Focus on specific change types--suggest-css- Generate CSS fix suggestions--css-selector <selector>- CSS selector for fixes--embed-metadata- Embed metadata in PNG output
Examples:
# Basic diff
aid diff before.png after.png diff.png
# Smart diff with CSS suggestions
aid diff before.png after.png diff.png --smart-diff --suggest-css
# Focus on specific changes
aid diff before.png after.png diff.png -f content,styleProcess multiple images in parallel.
aid batch <reference-dir> <target-dir> <output-dir> [options]Options:
-p, --pattern <pattern>- File pattern (default: "*.png")-r, --recursive- Scan recursively (default: true)-t, --threshold <percent>- Difference threshold (default: 0.1)--no-parallel- Disable parallel processing-c, --concurrency <n>- Worker count (default: 4)-e, --exclude <file>- Exclusions file-s, --smart- Enable smart classification--smart-pairing- Use fuzzy file matching
Example:
aid batch baseline/ current/ results/ -p "*.png" -c 8 --smart-pairingIteratively improve comparison accuracy.
aid refine <before> <after> <output-dir> [options]Options:
-e, --exclude <file>- Existing exclusions file--auto- Auto-apply high-confidence suggestions--exclude-types <types>- Types to auto-exclude--target <percent>- Target difference percentage--max-iterations <n>- Maximum iterations
Example:
aid refine before.png after.png refinement/ --auto --target 0.5Create an interactive HTML report from comparison results.
aid report <results-dir> [options]Example:
aid report comparison-results/Extract metadata embedded in PNG files.
aid read-metadata <image-file>These options work with all commands:
-h, --help- Display help-v, --version- Display version--verbose- Enable verbose logging--quiet- Suppress output except errors
Create an exclusions.json file to ignore specific regions:
{
"regions": [
{
"name": "timestamp",
"bounds": { "x": 10, "y": 10, "width": 200, "height": 30 },
"reason": "Dynamic timestamp"
}
]
}AID_CONCURRENCY- Default worker count for batch processingAID_THRESHOLD- Default difference thresholdAID_COLOR- Default highlight color
aligned.png- Aligned target imagediff.png- Visual differencereport.json- Comparison statisticsmetadata.json- Extended metadata
diff-smart-report.json- Classification datadiff-smart-report.html- Interactive reportdiff-fixes.css- CSS suggestions
batch-report.html- Interactive summarybatch-report.json- Complete results- Individual comparison directories
0- Success1- General error2- Invalid arguments3- File not found4- ImageMagick not found5- Processing error
# Increase concurrency for large batches
aid batch ref/ target/ out/ -c 16
# Disable parallel for debugging
aid batch ref/ target/ out/ --no-parallel# Full smart analysis
aid compare before.png after.png results/ \
--smart \
--smart-diff \
--suggest-css \
--embed-metadata
# Focus on UI changes only
aid diff before.png after.png diff.png \
-f style,layout \
--suggest-css \
--css-selector ".my-component"# Strict mode for CI
aid compare baseline.png screenshot.png results/ \
-t 0.01 \
-e ci-exclusions.json \
|| exit 1- Programmatic Usage - Using as a library
- Batch Processing Guide - Advanced batch features
- CI Integration - CI/CD setup