use std::error::Error;
use avif::{AvifEncoder, BitDepth, EncoderConfig};
const SOURCE: &str = concat!(env!("CARGO_MANIFEST_DIR"), "/assets/image.jpg");
fn main() -> Result<(), Box<dyn Error>> {
let img = image::open(SOURCE)?;
let config = EncoderConfig {
bit_depth: BitDepth::Ten,
..Default::default()
};
let mut bytes = Vec::new();
img.write_with_encoder(AvifEncoder::new_with_config(&mut bytes, config))?;
let info = avif::probe(&bytes)?;
println!("encoded {} bytes at {:?}", bytes.len(), info.bit_depth);
let out = concat!(env!("CARGO_MANIFEST_DIR"), "/assets/high-bit-depth-example.avif");
std::fs::write(out, &bytes)?;
println!("saved -> {}", out);
Ok(())
}