use std::error::Error;
use webp::WebpEncoder;
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(
WebpEncoder::new(&mut bytes)
.with_quality(80) .with_compression(6) .with_threads(true), )?;
let out = concat!(env!("CARGO_MANIFEST_DIR"), "/assets/custom-encoder-example.webp");
std::fs::write(out, &bytes)?;
println!("encoded {} bytes (quality 80, compression 6) -> {}", bytes.len(), out);
Ok(())
}