//! Report the defect map a raw file carries, if it carries one. //! //! ```text //! cargo run -p dr-decode --example defects -- IMG_6320.dng photo.cr2 //! ``` //! //! Exists because whether this is worth building a correction stage for is a //! question about *your files*, not about the specification: DNGs written by //! cameras that map their own sensors carry `OpcodeList1`, conversions from a //! proprietary raw usually do not, and no CR2 or scanner TIFF ever does. //! Rather than guess, point this at the library and see. fn main() { let files: Vec = std::env::args().skip(1).collect(); if files.is_empty() { eprintln!("usage: defects ..."); std::process::exit(2); } for path in &files { let bytes = match std::fs::read(path) { Ok(b) => b, Err(e) => { println!("{path}: unreadable — {e}"); continue; } }; let found = dr_decode::defects(&bytes); if found.is_empty() { println!("{path}: no defect map"); continue; } println!( "{path}: {} bad pixel(s), {} bad line(s)", found.pixels.len(), found.lines.len() ); // A handful, so the output stays readable on a sensor reporting // hundreds — the count above is the number that matters. for p in found.pixels.iter().take(8) { println!(" pixel at {},{}", p.x, p.y); } for l in found.lines.iter().take(8) { match l { dr_decode::BadLine::Column(x) => println!(" dead column {x}"), dr_decode::BadLine::Row(y) => println!(" dead row {y}"), } } } }