//! Compare two PNGs with the cross-renderer tolerance; exits nonzero on //! mismatch. Used by scripts that compare vello and software screenshots of //! the same scene. use guiduck_render_tinyskia::diff::{DiffTolerance, compare}; use tiny_skia::Pixmap; fn main() { let args: Vec = std::env::args().collect(); let [_, a_path, b_path] = args.as_slice() else { eprintln!("usage: png-diff "); std::process::exit(2); }; let a = Pixmap::load_png(a_path).unwrap_or_else(|e| { eprintln!("failed to load {a_path}: {e}"); std::process::exit(2); }); let b = Pixmap::load_png(b_path).unwrap_or_else(|e| { eprintln!("failed to load {b_path}: {e}"); std::process::exit(2); }); match compare(&a, &b, DiffTolerance::CROSS_RENDERER) { None => { eprintln!( "size mismatch: {}x{} vs {}x{}", a.width(), a.height(), b.width(), b.height() ); std::process::exit(1); } Some((stats, passes)) => { println!( "differing: {:.4}% max channel diff: {} mean: {:.4}", stats.differing_fraction * 100.0, stats.max_channel_diff, stats.mean_channel_diff ); std::process::exit(if passes { 0 } else { 1 }); } } }