use oximg::pipeline::{self, Params};
fn main() -> anyhow::Result<()> {
let args: Vec<String> = std::env::args().collect();
let [_, input, max_w, max_h, output] = args.as_slice() else {
eprintln!("usage: thumbnail <input> <max_w> <max_h> <output>");
std::process::exit(2);
};
let params = Params {
max_width: max_w.parse()?,
max_height: max_h.parse()?,
..Default::default()
};
let (bytes, format) = pipeline::process_path(input.as_ref(), ¶ms)?;
std::fs::write(output, &bytes)?;
let (_, w, h) = pipeline::probe(&bytes)?;
println!(
"wrote {output} ({} bytes, {w}x{h}, {})",
bytes.len(),
format.content_type()
);
Ok(())
}