Skip to content

image-slash-star

CI Documentation Benchmarks Release Latest release

Latest release: 0.1.3.

Rust codecs for detecting, inspecting, decoding, and encoding image bytes. Supports selected JPEG, PNG, GIF, BMP, TIFF, WebP, and ICO/CUR operations, with optional partial AVIF decoding.

Documentation · Supported formats · Benchmark results

Install

Add the crates.io package to your application's Cargo.toml:

[dependencies]
image-slash-star = "=0.1.3"

Requires Rust 1.96.1 or newer. There is one Cargo package and no npm or PyPI package. Applications own filesystem and network I/O; the API uses bytes and Rust values.

Encode and decode a PNG

use image_slash_star::{
    ColorType, DecodedImage, ImageFormat, ImageResult, decode, encode_default,
};

fn main() -> ImageResult<()> {
    let image = DecodedImage::try_new(
        3, 2, [255, 12, 34].repeat(6), ColorType::Rgb8,
    )?;
    let png = encode_default(&image, ImageFormat::Png)?;
    let decoded = decode(&png)?;
    assert_eq!(decoded.format, ImageFormat::Png);
    assert_eq!(decoded.content.pixels, image.pixels);
    Ok(())
}

The checked constructor validates dimensions and pixel layout. RGB8 data is tightly packed, row-major RGB bytes. decode detects the input format; encoding requires an explicit output format. Continue with API usage.

Choose formats

Feature Enabled by default Scope
jpeg, png, gif, bmp, tiff, webp Yes Selected decoding, encoding, and metadata operations
ico Yes ICO/CUR; also enables PNG and BMP
avif No Partial still-image decoder and container inspection; no supported encoder
jpeg-wide-color No Optional SIMD JPEG color conversion

Disable unused formats with default-features = false and an explicit Cargo features list. See supported formats and limitations. Resizing, drawing, filtering, and other image editing are outside this crate; use an image-processing library such as pillow-rs.

Errors and resource limits

Handle typed error kinds, stages, and reasons. Diagnostic text can change. Decode and encode policies offer input, result, and work limits; defaults are unlimited. They do not bound every intermediate allocation or wall-clock time. Read error recovery and limits before processing untrusted files.

Performance

View benchmark results for JPEG comparisons with TurboJPEG. Results identify their source revision and hardware; they do not represent every codec or general image processing.

Contribute and get help

Contributing covers source builds, tests, and benchmark work. The contributor references include the Generated capability and direct-mode tables and evidence guide. Support · Security · Releases · Changelog · Code of conduct

This project contains original and translated work under multiple licenses. Read NOTICE.md and third-party attribution before redistributing it.

Acknowledgements

Thank you to the codec authors credited in NOTICE.md for their implementations, research, and test material.