@blazediff/cli
CLI for image comparison. Wraps the native Rust binary (fastest), JS pixel diff, GMSD, SSIM, MS-SSIM, and Hitchhikerโs SSIM.
Installation
Global Installation
npm install -g @blazediff/cliLocal Installation
npm install --save-dev @blazediff/cliUsing npx
npx blazediff-cli image1.png image2.png -o diff.pngAvailable Commands
core-native (default)
blazediff-cli core-native (default)
Native Rust binary with SIMD optimization. The fastest option - 3-4x faster than odiff on large images.
Basic Usage
# Default command (core-native)
blazediff-cli image1.png image2.png -o diff.png
# Or explicitly
blazediff-cli core-native image1.png image2.png -o diff.pngWith Options
blazediff-cli image1.png image2.png -o diff.png --threshold 0.05 --no-antialiasingOptions
core-native, core and core-wasm take the same flags as the Rust blazediff CLI. Anti-aliased pixels are detected and left out of the count unless you pass --no-antialiasing.
blazediff-cli core-native <image1> <image2> [options]
Options:
-o, --output <path> Output path for the diff image
-t, --threshold <num> Matching threshold (0 to 1, default: 0.1)
--no-antialiasing Count anti-aliased pixels as differences
--metric <name> Color metric: yiq (default) or oklab (pixelmatch 8)
--mask <path> Image whose non-black pixels are skipped
--window <n> Also report the nรn window with the most differences
-a, --alpha <num> Opacity of the original image in the diff (default: 0.1)
--diff-color <r,g,b> Color for different pixels (default: 255,0,0)
--diff-color-alt <r,g,b> Color for pixels that get darker (default: diff color)
--aa-color <r,g,b> Color for anti-aliased pixels (default: 255,255,0)
--background <name> faded (default) or transparent
--json Print the result as JSON
--compression <num> PNG compression level (0-9, default: 0)
--quality <num> JPEG quality (1-100, default: 90)
-h, --help Show this help message--json prints the result object, for example {"kind":"compared","count":121,"percentage":0.09,"identical":false}.
Exit Codes
0- Images are identical1- Images differ, or their dimensions do not match2- Error (file not found, invalid format, etc.)
blazediff-cli image1.png image2.png -o diff.png
if [ $? -eq 0 ]; then
echo "Images match!"
else
echo "Images differ!"
fiWhy so fast? Uses a two-pass block-based algorithm with SIMD acceleration (NEON on ARM, SSE4.1 on x86). The cold pass quickly identifies unchanged blocks, then the hot pass only processes changed regions.
When to Use Each Algorithm
| Algorithm | Best for |
|---|---|
core-native (default) | Maximum speed, CI/CD, large images |
core | No native dependencies, runs anywhere Node runs |
gmsd | Similarity score, compression-tolerant |
ssim | MATLAB-compatible, research |
msssim | Multi-scale, varying resolutions |
hitchhikers-ssim | Fast SSIM (~4x), large batches |
Links
Last updated on