Skip to main content

blazediff

High-performance image diffing with block-based optimization and SIMD acceleration.

Crates.io npm PyPI License: MIT

Features

  • Block-based optimization - Skip identical regions for massive speedups on similar images
  • SIMD acceleration - Native SSE4.1 (x86) and NEON (ARM) implementations
  • Multiple formats - PNG, JPEG, and QOI support, via blazediff-shared
  • Perceptual diffing - YIQ-based color difference with antialiasing detection
  • In-house PNG codec - optional blazediff_png, faster than spng on every fixture, with byte-exact decode parity; opt-in via BLAZEDIFF_PNG_ENABLED
  • Cross-platform - Linux, macOS, and Windows support
  • Multi-language - Native Rust crate, Node.js (N-API), and Python (PyO3) bindings - all sharing the same core

Installation

Rust (CLI + library)

cargo install blazediff

Node.js - @blazediff/core-native

npm install @blazediff/core-native

N-API bindings shipped as pre-built .node binaries for macOS, Linux, and Windows (arm64 + x64). Built from this crate's napi Cargo feature.

import { diff } from "@blazediff/core-native";

const result = await diff("expected.png", "actual.png", {
  output: "diff.png",
  threshold: 0.1,
});
if (result.kind === "compared" && !result.identical) {
  console.log(`${result.count} pixels differ`);
}

Python - blazediff

pip install blazediff

PyO3 bindings shipped as abi3-py38 wheels for CPython ≥ 3.8 (macOS, Linux manylinux, Windows; arm64 + x86_64). Built from this crate's python Cargo feature.

from blazediff import diff

result = diff("expected.png", "actual.png", "diff.png", threshold=0.1)
if result.kind == "compared" and not result.identical:
    print(f"{result.count} pixels differ ({result.percentage:.2f}%)")

diff(a, b, output=None, *, threshold=0.1, antialiasing=True, metric="yiq", mask=None, window=None, alpha=0.1, diff_color=None, diff_color_alt=None, aa_color=None, background="faded", compression=0, quality=90) takes file paths or encoded bytes. The result has a kind:

kind Fields
"compared" count, percentage, identical, and window (x, y, count) when window is set
"dimension-mismatch" a and b, each with width and height
"io-error" path (when known) and message

Invalid options raise ValueError.

CLI Usage

# Basic diff
blazediff image1.png image2.png -o diff.png

# With custom threshold (0.0 - 1.0)
blazediff image1.png image2.png -o diff.png -t 0.1

# pixelmatch 8 metric, a mask, and the busiest 16×16 window, as JSON
blazediff image1.png image2.png --metric oklab --mask mask.png --window 16 --json
Flag Meaning
-o, --output <path> Write the diff image (only when the images differ)
-t, --threshold <n> Color difference threshold (0-1). Default: 0.1
--antialiasing, --no-antialiasing Detect anti-aliased pixels and leave them out of the count. Default: on
--metric <yiq|oklab> Color metric. oklab is pixelmatch 8's. Default: yiq
--mask <path> Image the size of the inputs; its non-black pixels are skipped
--window <n> Also report the N×N window with the most diff pixels
-a, --alpha <n> Opacity of the faded background. Default: 0.1
--diff-color, --diff-color-alt, --aa-color <r,g,b> Output colors
--background <faded|transparent> What the diff image shows under the diff. Default: faded
-c, --compression <0-9>, -q, --quality <1-100> PNG and JPEG encoder settings
--json Print the result object as JSON

Exit codes: 0 identical, 1 the images differ or their dimensions do not match, 2 error. With --json, a result prints to stdout ({"kind":"compared","count":..,"percentage":..,"identical":..}, or {"kind":"dimension-mismatch","a":{..},"b":{..}}) and an error prints to stderr ({"kind":"io-error","path":..,"message":..}).

Library Usage

use blazediff::{diff, load_png, save_png, DiffOptions, DiffResult, Image, Metric};

let a = load_png("image1.png")?;
let b = load_png("image2.png")?;
let mut output = Image::new(a.width, a.height);
let options = DiffOptions {
    threshold: 0.1,
    metric: Metric::Oklab,
    window: Some(16),
    ..Default::default()
};

match diff(&a, &b, Some(&mut output), &options)? {
    DiffResult::Compared { count, window, .. } => {
        println!("Different pixels: {count}, busiest window: {window:?}");
        save_png(&output, "diff.png")?;
    }
    DiffResult::DimensionMismatch { a, b } => println!("Sizes differ: {a:?} vs {b:?}"),
}

DiffOptions holds threshold, antialiasing (default true), metric (Yiq or Oklab), mask (one byte per pixel, non-zero is skipped), window, and render (alpha, diff_color, diff_color_alt, aa_color, background). diff returns Err only for buffers that do not match their size and masks of the wrong length.

Structural similarity

This crate is a pixel diff: it answers where two images differ. For how alike they look — SSIM, MS-SSIM, Hitchhiker's SSIM — use blazediff-ssim, which stands alone and shares nothing with this crate but the blazediff-shared primitives. It is also what @blazediff/ssim-native wraps.

Interpret

Structured region analysis that produces human-readable change descriptions. It is not part of this crate: it lives in blazediff-interpret, which consumes what diff returns, with its own blazediff-interpret CLI.

The classifier is independent of whatever found the regions. Anything that can say where something changed can drive it: blazediff-ssim by thresholding a score map, or a caller passing boxes directly. Coarse boxes are fine — each is refined against the source pixels before any statistic is computed, so the analysis stays per-pixel.

See INTERPRET.md for the full algorithm documentation - pipeline stages, formulas, classification rules, and output format.

Performance

5.1-5.9x faster than odiff, 8x faster than pixelmatch on 4K images.

Image I/O lives in blazediff-shared, shared with the other crates; load_png, save_jpeg and friends are re-exported here unchanged. PNG encode uses the in-house blazediff_png codec. A diff image has few colors, so it is written as a palette PNG: the decoded pixels are the same and the file is about 4x smaller. PNG decode defaults to spng. Setting BLAZEDIFF_PNG_ENABLED=1 routes decode through blazediff_png too, which is faster than spng on every fixture.

License

MIT

Metadata

Release files for blazediff 8.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distributions (wheels)

Table of built distributions (wheels) for blazediff 8.1.0
File Actions
blazediff-8.1.0-cp38-abi3-win_arm64.whl CPython 3.8 abi3 Windows ARM64 Details for blazediff-8.1.0-cp38-abi3-win_arm64.whl
blazediff-8.1.0-cp38-abi3-win_amd64.whl CPython 3.8 abi3 Windows x86-64 Details for blazediff-8.1.0-cp38-abi3-win_amd64.whl
blazediff-8.1.0-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.8 abi3 Linux glibc 2.17+ x86-64 Details for blazediff-8.1.0-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
blazediff-8.1.0-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl CPython 3.8 abi3 Linux glibc 2.17+ ARM64 Details for blazediff-8.1.0-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
blazediff-8.1.0-cp38-abi3-macosx_11_0_arm64.whl CPython 3.8 abi3 macOS 11.0+ ARM64 Details for blazediff-8.1.0-cp38-abi3-macosx_11_0_arm64.whl
blazediff-8.1.0-cp38-abi3-macosx_10_12_x86_64.whl CPython 3.8 abi3 macOS 10.12+ x86-64 Details for blazediff-8.1.0-cp38-abi3-macosx_10_12_x86_64.whl

Total release size: 3.8 MB

Release files / blazediff-8.1.0-cp38-abi3-win_arm64.whl

Download URL blazediff-8.1.0-cp38-abi3-win_arm64.whl
Size 573.2 kB
Tags CPython 3.8 Windows ARM64 abi3
SHA-256 checksum
How to use checksums
6ce7af2af2760c4ff5a090585c2e2888634cbb91bc187bf921fa47de47b8ac2c
BLAKE2b-256 checksum
How to use checksums
3e45a1ce4281423eebb5d0a8e24ba26c4404234f3f783219b67fe4c2c64c2d4a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via maturin/1.16.0

Release files / blazediff-8.1.0-cp38-abi3-win_amd64.whl

Download URL blazediff-8.1.0-cp38-abi3-win_amd64.whl
Size 602.5 kB
Tags CPython 3.8 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
1648f5286163cb9d9fa579adb89f3aa5e3c7421a7bd2de72f24e38b22c32c3c3
BLAKE2b-256 checksum
How to use checksums
d3d8e0631454f67f8842912274696abe8a015ee8eb0dd63ac2349c30f75b18df
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via maturin/1.16.0

Release files / blazediff-8.1.0-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL blazediff-8.1.0-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 700.3 kB
Tags CPython 3.8 Linux glibc 2.17+ x86-64 abi3
SHA-256 checksum
How to use checksums
b9cc055688140ec3bb684eb5a760eff626035ab596a6100e5e17dabb07a46e2e
BLAKE2b-256 checksum
How to use checksums
bc27df3db51d7992b20fc11dd99ce5750e494a624d03989587fb0ef12bc105a2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via maturin/1.16.0

Release files / blazediff-8.1.0-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl

Download URL blazediff-8.1.0-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Size 653.8 kB
Tags CPython 3.8 Linux glibc 2.17+ ARM64 abi3
SHA-256 checksum
How to use checksums
4444fe0f3140a782e3cf1561483b55d60ae5ce7636ffb81424a61098b0b5c7b2
BLAKE2b-256 checksum
How to use checksums
7bfca4c9bc7d0bcc01af17b4361f3b6bbbb01370a1391cc641c8c73fef254683
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via maturin/1.16.0

Release files / blazediff-8.1.0-cp38-abi3-macosx_11_0_arm64.whl

Download URL blazediff-8.1.0-cp38-abi3-macosx_11_0_arm64.whl
Size 593.5 kB
Tags CPython 3.8 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
d5ab46f2c64b7710b6ab619948f4034b0a7086f94ac4e7927b27180d22884fa3
BLAKE2b-256 checksum
How to use checksums
fc6f5c10979dbbd8f26a19fe99ff8b022f9f6ca288e8824cf1c2aa5a9c511a5d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via maturin/1.16.0

Release files / blazediff-8.1.0-cp38-abi3-macosx_10_12_x86_64.whl

Download URL blazediff-8.1.0-cp38-abi3-macosx_10_12_x86_64.whl
Size 628.7 kB
Tags CPython 3.8 abi3 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
cfef8e56ca1c5feebd9c08df20d6d9330e9a6c9f6d8752a736f247ed80de9319
BLAKE2b-256 checksum
How to use checksums
8f387d96253daaa2be82255b7848454648ee4b03205765edbb15df0c569bf293
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via maturin/1.16.0

Security for blazediff 8.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page