()
| 359 | } |
| 360 | |
| 361 | fn main() -> ExitCode { |
| 362 | let args = match parse_args() { |
| 363 | Ok(a) => a, |
| 364 | Err(e) => { |
| 365 | eprintln!("error: {e}"); |
| 366 | return ExitCode::from(2); |
| 367 | } |
| 368 | }; |
| 369 | |
| 370 | let reference_pixels = match load_rgb_normalized(Path::new(&args.reference_path)) { |
| 371 | Ok(p) => p, |
| 372 | Err(e) => { |
| 373 | eprintln!("error loading reference: {e}"); |
| 374 | return ExitCode::from(1); |
| 375 | } |
| 376 | }; |
| 377 | let candidate_pixels = match load_rgb_normalized(Path::new(&args.candidate_path)) { |
| 378 | Ok(p) => p, |
| 379 | Err(e) => { |
| 380 | eprintln!("error loading candidate: {e}"); |
| 381 | return ExitCode::from(1); |
| 382 | } |
| 383 | }; |
| 384 | |
| 385 | // We need the dimensions explicitly for SSIM windowing + heatmap |
| 386 | // output — load the raw images once more (cheap; we already have |
| 387 | // them in memory via the decoder). |
| 388 | let reference_img = match image::open(&args.reference_path) { |
| 389 | Ok(img) => img.to_rgb8(), |
| 390 | Err(e) => { |
| 391 | eprintln!("error re-opening reference: {e}"); |
| 392 | return ExitCode::from(1); |
| 393 | } |
| 394 | }; |
| 395 | let candidate_img = match image::open(&args.candidate_path) { |
| 396 | Ok(img) => img.to_rgb8(), |
| 397 | Err(e) => { |
| 398 | eprintln!("error re-opening candidate: {e}"); |
| 399 | return ExitCode::from(1); |
| 400 | } |
| 401 | }; |
| 402 | |
| 403 | if reference_img.dimensions() != candidate_img.dimensions() { |
| 404 | eprintln!( |
| 405 | "error: image dimensions mismatch — reference {}x{}, candidate {}x{}", |
| 406 | reference_img.width(), |
| 407 | reference_img.height(), |
| 408 | candidate_img.width(), |
| 409 | candidate_img.height() |
| 410 | ); |
| 411 | return ExitCode::from(1); |
| 412 | } |
| 413 | if reference_pixels.len() != candidate_pixels.len() { |
| 414 | eprintln!("error: pixel count mismatch despite matching dimensions?"); |
| 415 | return ExitCode::from(1); |
| 416 | } |
| 417 | |
| 418 | let (width, height) = reference_img.dimensions(); |
nothing calls this directly
no test coverage detected