Skip to Content
New: codec-png-native and codec-png-wasm bring the blazediff-png codec to Node and WebAssembly, faster than spng and jSquash. Read more โ†’
APIs@blazediff/cli

@blazediff/cli

CLI for image comparison. Wraps the native Rust binary (fastest), JS pixel diff, GMSD, SSIM, MS-SSIM, and Hitchhikerโ€™s SSIM.

View Detailed Benchmarksย 

Installation

Global Installation

npm install -g @blazediff/cli

Local Installation

npm install --save-dev @blazediff/cli

Using npx

npx blazediff-cli image1.png image2.png -o diff.png

Available Commands

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.png

With Options

blazediff-cli image1.png image2.png -o diff.png --threshold 0.05 --no-antialiasing

Options

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 identical
  • 1 - Images differ, or their dimensions do not match
  • 2 - 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!" fi

Why 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

AlgorithmBest for
core-native (default)Maximum speed, CI/CD, large images
coreNo native dependencies, runs anywhere Node runs
gmsdSimilarity score, compression-tolerant
ssimMATLAB-compatible, research
msssimMulti-scale, varying resolutions
hitchhikers-ssimFast SSIM (~4x), large batches
Last updated on