img2avif 0.1.2

Convert images to AVIF format.
Documentation
  • Coverage
  • 66.67%
    2 out of 3 items documented0 out of 2 items with examples
  • Size
  • Source code size: 4.08 MB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 171.65 kB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 48s Average build duration of successful builds.
  • all releases: 54s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • TnZzZHlp

img2avif

Convert images to AVIF format.

Usage

This library provides a function img2avif to convert image data into the AVIF format.

use std::fs::File;
use img2avif::img2avif; // Assuming your crate root is named img2avif

fn main() -> Result<(), Box<dyn std::error::Error>> {
    let file = File::open("path/to/your/image.png")?; // Supports PNG, JPEG, WebP, etc. supported by the image crate

    // Optional speed (0-10, 0=best quality, 10=fastest) and quality (0-100, 100=lossless)
    let speed = Some(1); // Default: 1
    let quality = Some(90); // Default: 100

    let avif_data = img2avif(file, speed, quality)?;

    std::fs::write("output.avif", avif_data)?;

    println!("Successfully converted image to AVIF!");
    Ok(())
}

See src/lib.rs for the function implementation and tests for more examples.

Dependencies

  • image (version 0.25.6 with "avif" feature)

Building and Testing

# Build the project

cargo build


# Run tests

cargo test

License

This project is licensed under the MIT License. See the Cargo.toml file for details.