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.0.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.0.0
File Actions
blazediff-8.0.0-cp38-abi3-win_arm64.whl CPython 3.8 abi3 Windows ARM64 Details for blazediff-8.0.0-cp38-abi3-win_arm64.whl
blazediff-8.0.0-cp38-abi3-win_amd64.whl CPython 3.8 abi3 Windows x86-64 Details for blazediff-8.0.0-cp38-abi3-win_amd64.whl
blazediff-8.0.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.0.0-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
blazediff-8.0.0-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl CPython 3.8 abi3 Linux glibc 2.17+ ARM64 Details for blazediff-8.0.0-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
blazediff-8.0.0-cp38-abi3-macosx_11_0_arm64.whl CPython 3.8 abi3 macOS 11.0+ ARM64 Details for blazediff-8.0.0-cp38-abi3-macosx_11_0_arm64.whl
blazediff-8.0.0-cp38-abi3-macosx_10_12_x86_64.whl CPython 3.8 abi3 macOS 10.12+ x86-64 Details for blazediff-8.0.0-cp38-abi3-macosx_10_12_x86_64.whl

Total release size: 3.8 MB

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

Download URL blazediff-8.0.0-cp38-abi3-win_arm64.whl
Size 573.5 kB
Tags CPython 3.8 Windows ARM64 abi3
SHA-256 checksum
How to use checksums
d72323cf3924f6ebec50f7b2aa544c078a84dbcd1f7b82933c15ba42a94223ff
BLAKE2b-256 checksum
How to use checksums
029494086c1ad7ada0c8b6f2d68c0a2d528c888434eec9d43e80951720bc1dae
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via maturin/1.16.0

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

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

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

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

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

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

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

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

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

Download URL blazediff-8.0.0-cp38-abi3-macosx_10_12_x86_64.whl
Size 629.1 kB
Tags CPython 3.8 abi3 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
732208722b98ba483e3abc9f1d6342282faf203bec024690603eacbcb2ce5d2d
BLAKE2b-256 checksum
How to use checksums
1a0e3544702372299eec218861957a8de43ce104118e2e3abe8a0d663b3341a3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via maturin/1.16.0

Security for blazediff 8.0.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