Expand description
The primitives every BlazeDiff crate sits on: the Image buffer, yiq
color math, and RGBA8 decode/encode for PNG, JPEG and QOI.
It exists because the crates above it form a chain — blazediff-interpret
depends on both blazediff and blazediff-ssim, which know nothing about
each other — so anything two of them share has to live below all of them.
Every decoder normalizes to Image, so the compute crates never see a
codec; PNG goes through vendored libspng, JPEG through vendored
libjpeg-turbo, QOI through qoi-rust.
use blazediff_shared::{load_image_pair, save_image, ImageFormat};
let (a, b) = load_image_pair("a.png", "b.jpg").unwrap();
assert_eq!(ImageFormat::from_path("a.png"), Some(ImageFormat::Png));Without the default codecs feature the crate is pure Rust and compiles to
wasm32: Image, ImageError, ImageFormat and yiq remain, which
is all the wasm build of blazediff needs.
Re-exports§
pub use jpeg_io::decode_jpeg;pub use jpeg_io::load_jpeg;pub use jpeg_io::load_jpegs;pub use jpeg_io::save_jpeg;pub use png_io::decode_png;pub use png_io::encode_png;pub use png_io::load_png;pub use png_io::load_pngs;pub use png_io::save_png;pub use png_io::save_png_with_compression;pub use qoi_io::decode_qoi;pub use qoi_io::load_qoi;pub use qoi_io::load_qois;pub use qoi_io::save_qoi;
Modules§
- jpeg_io
- JPEG I/O via libjpeg-turbo (TurboJPEG API).
- png_io
- PNG I/O: spng handles all decode and encode by default. The experimental
in-house
blazediff_pngcodec is opt-in viacrate::blazediff_png_enabled— when enabled it takes the decode and stored-block (level 0) encode paths, with spng staying as the defensive decode fallback. - qoi_io
- QOI I/O via qoi-rust (https://github.com/aldanor/qoi-rust).
- spng_
ffi - yiq
- YIQ color space calculations.
Structs§
- Image
- A decoded image: RGBA, 4 bytes per pixel, row-major.
Enums§
- Image
Error - Anything that can go wrong reading or writing an image.
- Image
Format - The container formats BlazeDiff reads and writes.
Functions§
- blazediff_
png_ enabled - Whether the in-house
blazediff_pngcodec takes the PNG paths. - decode_
image - Decode an encoded buffer, picking the decoder from its magic bytes.
- decode_
image_ pair - Decode two encoded buffers in parallel.
- load_
image - Load one image, picking the decoder from the file extension.
- load_
image_ pair - Load two images in parallel, picking each decoder from its file extension.
- save_
image - Write an image, picking the encoder from the file extension.