From d685e55d34e400cadc1d4abd3c7b944f1c7d0a27 Mon Sep 17 00:00:00 2001 From: Christopher Regali <60792386+ChrisRega@users.noreply.github.com> Date: Fri, 1 Mar 2024 22:17:49 +0100 Subject: [PATCH] Update src/image.rs Co-authored-by: Alexander Rohde --- src/image.rs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/image.rs b/src/image.rs index a695dc6..13758be 100644 --- a/src/image.rs +++ b/src/image.rs @@ -185,6 +185,19 @@ pub fn compare_paths>( )))?; let out_path = (nominal_file_name + "diff_image.png").to_string(); let mut result_diff = report::Difference::new_for_file(&nominal_path, &actual_path); + if result.score < config.threshold { + let out_path_set = if let Some(i) = result.image { + let nominal_file_name = + get_file_name(nominal_path.as_ref()).ok_or(Error::FileNameParsing(format!( + "Could not extract filename from path {:?}", + nominal_path.as_ref() + )))?; + let out_path = (nominal_file_name + "diff_image.png").to_string(); + i.save(&out_path)?; + Some(out_path) + } else { + None + }; if result.score < config.threshold { let out_path_set;