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

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

Total release size: 3.7 MB

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

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

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

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

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

Download URL blazediff-8.1.2-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
a4af5b0cdbeaef223b620d7894a7b48ebefe81d95b06229057fece7e4019b835
BLAKE2b-256 checksum
How to use checksums
ea8117e0fd30e5ae05e4b3a4cd440686b31c440665deee5c04136590dc8e6d0a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via maturin/1.16.0

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

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

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

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

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

Download URL blazediff-8.1.2-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
e26b5bb8bdbe2111d461b6451496d22a36e0aeeeff153c869b3e4000b83409bb
BLAKE2b-256 checksum
How to use checksums
d987557c39f4b26f94664b062a66c497faa8d254c327e624b3f82dc1d18b4500
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via maturin/1.16.0

Security for blazediff 8.1.2

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