iqa
iqa provides a single, ergonomic API over the patchwork of visual quality assessment metrics available in the Rust ecosystem. It wraps existing crates where they exist and fills in the gaps where they don't, so you can compute PSNR, SSIMULACRA2, and friends without juggling a different type, color space, and pixel format for each one.
Installation
This pulls in every metric. Some (such as ssimulacra2) compile vendored C/C++
and therefore need a C++ toolchain and the system lcms2 library — see
Cargo features for the details. For a pure-Rust build with no
system dependencies, disable the defaults and take just the metrics you need:
[]
= { = "0.1", = false, = ["psnr"] }
Quick start
iqa consumes a tightly packed, row-major sample buffer and deliberately
leaves image decoding to you (here, the image
crate):
use ;
Both inputs must share one pixel format, so a color-space, channel, or bit-depth
mismatch is a compile error rather than a meaningless score. See
examples/compare.rs for the full pipeline — run it with
cargo run --release --example compare -- reference.png distorted.jpg.
Metrics
The table below tracks the planned metric set — the nine-metric full-reference core that covers essentially every published JXL/AVIF codec comparison from the last two years, plus LPIPS as a learned reference metric.
The Implementation column points at the implementation iqa is built on. We prefer porting or binding the upstream source implementation over reusing a Rust-specific reimplementation: cross-compilation is a requirement, but portability beyond that is not, so staying close to the reference keeps results faithful.
| IQA | Implementation | Status |
|---|---|---|
| SSIMULACRA2 | cloudinary/ssimulacra2 | Require testing |
| Butteraugli | libjxl | Planned |
| DSSIM | kornelski/dssim | Planned |
| XPSNR | fraunhoferhhi/xpsnr | Planned |
| PSNR | Native implementation | Require testing |
| PSNR-HVS-M | xiph/daala — tools/psnrhvs.c |
Planned |
| SSIM | Native implementation | Planned |
| MS-SSIM | xiph/daala — tools/ssim.c |
Planned |
| CIEDE2000 | Native implementation | Planned |
| LPIPS | richzhang/PerceptualSimilarity | Not planned* |
*: LPIPS is Python implementation only.
Status legend:
- Planned — selected for implementation, not yet started.
- Require testing — implemented, but not yet validated against reference outputs.
- Stable and tested — implemented and verified against the reference implementation.
Cargo features
Each metric is gated behind its own Cargo feature:
| Feature | Default | Notes |
|---|---|---|
psnr |
yes | Native Rust; no system dependencies. |
ssimulacra2 |
yes | Binds the vendored C++ reference; see the build requirements below. |
Every metric is enabled by default for convenience — cargo add iqa
gets you the full set. Some metrics (such as ssimulacra2) bind native C/C++
code and therefore need a C++ toolchain and system libraries to build.
For leaner builds, disable the default features and opt into exactly the metrics you need:
[]
# Pure-Rust subset only — no C/C++ toolchain required.
= { = "0.1", = false, = ["psnr"] }
Building with ssimulacra2
SSIMULACRA2 is bound via FFI to the original C++ reference rather than reimplemented, so enabling it (including via the default feature set) needs a native build environment:
-
A C++ toolchain.
build.rscompiles the reference with thecccrate, which usesc++by default (override with theCXXenvironment variable). -
lcms2. libjxl's color management needs the system
lcms2library, located viapkg-config:
When you depend on iqa from crates.io that is all you need — the vendored
C++ sources are packaged inside the published crate, so there are no submodules
to fetch.
Building from a git checkout (contributors) additionally needs those
sources, which live under third_party/ as git submodules:
Either way, build or test with the feature enabled:
Development
It is important that development velocity is maintained regardless of project complexity. Unit tests for all contributions are expected, especially for platform-specific behaviours!
Setup
Install lefthook and activate the pre-commit and pre-push hooks:
# macOS / Homebrew
# Linux (Homebrew on Linux)
# via cargo
# then install the hooks
The pre-commit hook runs cargo fmt --check and cargo clippy.
The pre-push hook runs the full test suite.
Releasing
Releases are automated with release-plz and driven by
Conventional Commits: the commit messages
landed on master decide the next version number and fill in CHANGELOG.md.
To cut a release:
- Land changes on
masterwith Conventional Commit messages (feat:,fix:,refactor!:, ...). - release-plz maintains an open release PR that bumps the version in
Cargo.toml, updatesCHANGELOG.md, and refreshesCargo.lock. Review it as you would any other PR. - Merge the release PR. Merging it is the whole release: release-plz
publishes the crate to crates.io, pushes a
vX.Y.Zgit tag, and creates the matching GitHub release.
Publishing authenticates with crates.io
trusted publishing over OIDC, so no
registry token is stored in the repository. The workflow lives in
.github/workflows/release-plz.yml.
0.1.0 was published by hand to bootstrap the crate — trusted publishing can
only be configured once a crate already exists on crates.io. Every release after
it is fully automated by merging the release PR.