use std::error::Error;
use avif::AvifEncoder;
const SOURCE: &str = concat!(env!("CARGO_MANIFEST_DIR"), "/assets/image.jpg");
fn main() -> Result<(), Box<dyn Error>> {
let img = image::open(SOURCE)?;
let mut bytes = Vec::new();
img.write_with_encoder(
AvifEncoder::new(&mut bytes)
.with_quality(80) .with_speed(4) .with_threads(4), )?;
let out = concat!(env!("CARGO_MANIFEST_DIR"), "/assets/custom-encoder-example.avif");
std::fs::write(out, &bytes)?;
println!("encoded {} bytes (quality 80, speed 4) -> {}", bytes.len(), out);
Ok(())
}