@blazediff/cli

中文文档
6.0.0发布于 2026/11/05MITTypeScriptESM + CJS构建来源已验证近 30 天下载 2598

Command-line interface for the blazediff image comparison library

原始使用文档
文档目录15 节
  1. Installation
  2. Usage
  3. Commands
  4. core-native - Native binary comparison (default)
  5. core and core-wasm - JavaScript and WebAssembly pixel compa…
  6. gmsd - Gradient Magnitude Similarity Deviation
  7. ssim - Structural Similarity Index
  8. msssim - Multi-Scale Structural Similarity Index
  9. hitchhikers-ssim - Fast SSIM
  10. interpret - What changed, not just where
  11. Examples
  12. Codecs (for core , gmsd , ssim , msssim )
  13. Exit Codes
  14. core-native/core Mode
  15. GMSD, SSIM, MS-SSIM Modes

@blazediff/cli

npm bundle size NPM Downloads

Command-line interface for the BlazeDiff image comparison library.

Installation

npm install -g @blazediff/cli

Usage

blazediff-cli <command> <image1> <image2> [options]

Commands

BlazeDiff supports multiple comparison algorithms, each optimized for different use cases:

core-native - Native binary comparison (default)

The fastest option. Uses the native Rust binary with SIMD optimization for maximum performance.

blazediff-cli image1.png image2.png -o diff.png [options]
# Or explicitly:
blazediff-cli core-native image1.png image2.png -o diff.png [options]

core-native, core and core-wasm take the same flags as the Rust blazediff CLI:

  • -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 (detection is on by default)
  • --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 <faded|transparent> - What the diff image shows under the diff (default: faded)
  • --json - Print the result object as JSON

core-native also takes --compression <0-9> and --quality <1-100>. core and core-wasm also take --codec <pngjs|sharp|jsquash-png>.

Exit codes: 0 identical, 1 the images differ or their dimensions do not match, 2 error.

core and core-wasm - JavaScript and WebAssembly pixel comparison

No native dependencies. core-wasm runs the same Rust algorithm as core-native.

blazediff-cli core image1.png image2.png [options]
blazediff-cli core-wasm image1.png image2.png [options]

gmsd - Gradient Magnitude Similarity Deviation

Perceptual quality metric based on gradient similarity.

blazediff-cli gmsd image1.png image2.png [options]

Options:

  • -o, --output <path> - Output path for GMS similarity map
  • --downsample <0|1> - Downsample factor (0=full-res, 1=2x, default: 0)
  • --gmsd-c <num> - Stability constant (default: 170)
  • --codec <name> - Specify codec to use (pngjs, sharp, jsquash-png)
  • -h, --help - Show help message

ssim - Structural Similarity Index

Industry-standard metric for measuring structural similarity.

blazediff-cli ssim image1.png image2.png [options]

Options:

  • -o, --output <path> - Output path for SSIM map visualization
  • --codec <name> - Specify codec to use (pngjs, sharp, jsquash-png)
  • -h, --help - Show help message

msssim - Multi-Scale Structural Similarity Index

Enhanced SSIM that operates at multiple image scales.

blazediff-cli msssim image1.png image2.png [options]

Options:

  • -o, --output <path> - Output path for MS-SSIM map visualization
  • --codec <name> - Specify codec to use (pngjs, sharp, jsquash-png)
  • -h, --help - Show help message

hitchhikers-ssim - Fast SSIM

Integral image-based SSIM implementation for faster computation.

blazediff-cli hitchhikers-ssim image1.png image2.png [options]

interpret - What changed, not just where

Structured region analysis: each change gets a type, a shape, a position and the statistics behind them. Every other command answers where pixels differ or how alike two images are; this one describes the change.

blazediff-cli interpret image1.png image2.png [output] [options]

output is written by the pixel source only — the metric sources and --regions have no diff visualization to write, and passing one is an error rather than a silently ignored path.

Options:

  • --source <name> - How to locate regions: pixel (default), ssim, ms-ssim, hitchhikers-ssim
  • -t, --threshold <num> - Color difference threshold (0 to 1, default: 0.1). pixel only
  • -a, --antialiasing - Exclude anti-aliased pixels. pixel only
  • -c, --compression <num> - PNG compression level (0-9, default: 0)
  • --window-size <num> - Local window size for the metric sources (default: 11)
  • --region-floor <num> - Window score at or below which it counts as changed (default: 0.99)
  • --regions <json> - Skip the search and classify these boxes instead
  • --json - Print the full result as JSON
  • -h, --help - Show help message

The metric sources locate regions by thresholding a similarity map, so their boxes are as coarse as that map's grid. The numbers are not: every box is refined against the source pixels first, so pixel counts stay per-pixel.

Exits 0 when nothing actionable changed, 1 when it did, 2 on error.

Examples

# Native binary diff (default, fastest)
blazediff-cli image1.png image2.png diff.png
blazediff-cli core-native image1.png image2.png diff.png -t 0.05 -a

# JavaScript pixel diff (more options)
blazediff-cli core image1.png image2.png -o diff.png -t 0.05

# GMSD similarity metric
blazediff-cli gmsd image1.png image2.png
blazediff-cli gmsd image1.png image2.png -o gms-map.png

# Describe what changed
blazediff-cli interpret image1.png image2.png
blazediff-cli interpret image1.png image2.png --source ms-ssim
blazediff-cli interpret image1.png image2.png --json

# SSIM structural similarity
blazediff-cli ssim image1.png image2.png
blazediff-cli ssim image1.png image2.png -o ssim-map.png

# MS-SSIM multi-scale similarity
blazediff-cli msssim image1.png image2.png
blazediff-cli msssim image1.png image2.png -o msssim-map.png

# Use Sharp codec for better performance (core/gmsd/ssim)
blazediff-cli core image1.jpg image2.jpg --codec sharp

Codecs (for core, gmsd, ssim, msssim)

  • pngjs (default) - Pure JavaScript, works everywhere. Supports PNG only.
  • sharp - Native bindings, significantly faster. Supports PNG and JPEG.
  • jsquash-png - WASM-based, zero native deps. Faster than pngjs. PNG only.

Exit Codes

core-native/core Mode

  • 0 - Images are identical
  • 1 - Images have differences
  • 2 - Error (file not found, invalid format, etc.)

GMSD, SSIM, MS-SSIM Modes

  • 0 - Images are highly similar (score >= 0.95)
  • 1 - Images have noticeable differences (score < 0.95) or error occurred

版本与发布记录

@blazediff/cli 共发布 34 个版本,首次发布于 2025/12/16;过去 12 个月发布了 34 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
6.0.0latest2026/11/053 天前
5.0.52026/10/2612 天前
5.0.42026/08/292 个月前
5.0.32026/08/272 个月前
5.0.22026/08/182 个月前
5.0.12026/08/182 个月前

关于 @blazediff/cli 的常见问题

@blazediff/cli 是什么?

Command-line interface for the blazediff image comparison library

如何安装 @blazediff/cli?

在项目目录运行 npm install @blazediff/cli,或使用 pnpm add / yarn add / bun add。它还提供命令行工具 blazediff-cli,可以用 npx blazediff-cli 直接运行。

@blazediff/cli 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@blazediff/cli 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@blazediff/cli 可以商用吗?

@blazediff/cli 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@blazediff/cli 的下载量有多少?

根据 npm 官方下载统计,@blazediff/cli 在 2026/10/09 – 2026/11/07 这 30 天内被下载 2,598 次,日均约 87 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@blazediff/cli 还在维护吗?

最新版本 6.0.0 发布于 2026/11/05(3 天前);至今共发布 34 个版本,其中过去 12 个月发布了 34 个;首次发布于 2025/12/16。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。