1
0
Fork 0
mirror of synced 2024-06-03 11:04:47 +12:00
This commit is contained in:
Rafał Mikrut 2023-12-16 22:55:19 +01:00
parent cc590d8946
commit 382375d403

View file

@ -341,19 +341,33 @@ impl SimilarImages {
fn collect_image_file_entry(&self, file_entry: &mut ImagesEntry) { fn collect_image_file_entry(&self, file_entry: &mut ImagesEntry) {
let img; let img;
match file_entry.image_type { if file_entry.image_type == ImageType::Heic {
ImageType::Normal | ImageType::Heic => { #[cfg(feature = "heif")]
if cfg!(feature = "heif") && file_entry.image_type == ImageType::Heic { {
#[cfg(feature = "heif")] img = match get_dynamic_image_from_heic(&file_entry.path.to_string_lossy()) {
{ Ok(t) => t,
img = match get_dynamic_image_from_heic(&file_entry.path.to_string_lossy()) { Err(_) => {
Ok(t) => t, return;
Err(_) => { }
return; };
} }
}; #[cfg(not(feature = "heif"))]
{
if let Ok(image_result) = panic::catch_unwind(|| image::open(&file_entry.path)) {
if let Ok(image2) = image_result {
img = image2;
} else {
return;
} }
} else { } else {
let message = crate::common::create_crash_message("Image-rs", &file_entry.path.to_string_lossy(), "https://github.com/image-rs/image/issues");
println!("{message}");
return;
}
}
} else {
match file_entry.image_type {
ImageType::Normal | ImageType::Heic => {
if let Ok(image_result) = panic::catch_unwind(|| image::open(&file_entry.path)) { if let Ok(image_result) = panic::catch_unwind(|| image::open(&file_entry.path)) {
if let Ok(image2) = image_result { if let Ok(image2) = image_result {
img = image2; img = image2;
@ -366,15 +380,15 @@ impl SimilarImages {
return; return;
} }
} }
} ImageType::Raw => {
ImageType::Raw => { img = match get_dynamic_image_from_raw_image(&file_entry.path) {
img = match get_dynamic_image_from_raw_image(&file_entry.path) { Some(t) => t,
Some(t) => t, None => return,
None => return, };
}; }
} _ => {
_ => { unreachable!();
unreachable!(); }
} }
} }