Skip to content

Commit de9f703

Browse files
authored
Webp preview workaround remove (#923)
1 parent 1c76d34 commit de9f703

File tree

2 files changed

+19
-58
lines changed

2 files changed

+19
-58
lines changed

czkawka_gui/src/connect_things/connect_button_compare.rs

+1-20
Original file line numberDiff line numberDiff line change
@@ -357,9 +357,8 @@ fn generate_cache_for_results(vector_with_path: Vec<(String, String, TreePath)>)
357357
let mut pixbuf = get_pixbuf_from_dynamic_image(&DynamicImage::new_rgb8(1, 1)).unwrap();
358358
let name_lowercase = name.to_lowercase();
359359
let is_heic = HEIC_EXTENSIONS.iter().any(|extension| name_lowercase.ends_with(extension));
360-
let is_webp = name.to_lowercase().ends_with(".webp");
361360

362-
if is_heic || is_webp {
361+
if is_heic {
363362
#[allow(clippy::never_loop)]
364363
'czystka: loop {
365364
#[cfg(feature = "heif")]
@@ -381,24 +380,6 @@ fn generate_cache_for_results(vector_with_path: Vec<(String, String, TreePath)>)
381380
};
382381
break 'czystka;
383382
}
384-
if is_webp {
385-
match image::open(&full_path) {
386-
Ok(t) => {
387-
match get_pixbuf_from_dynamic_image(&t) {
388-
Ok(t) => {
389-
pixbuf = t;
390-
}
391-
Err(e) => {
392-
println!("Failed to open image {full_path}, reason {e}");
393-
}
394-
};
395-
}
396-
Err(e) => {
397-
println!("Failed to open image {full_path}, reason {e}");
398-
}
399-
};
400-
break 'czystka;
401-
}
402383
break 'czystka;
403384
}
404385
} else {

czkawka_gui/src/initialize_gui.rs

+18-38
Original file line numberDiff line numberDiff line change
@@ -575,56 +575,33 @@ fn show_preview(
575575
}
576576

577577
let is_heic;
578-
let is_webp;
579578
if let Some(extension) = Path::new(&name).extension() {
580579
let extension = format!(".{}", extension.to_string_lossy().to_lowercase());
581580
is_heic = HEIC_EXTENSIONS.contains(&extension.as_str());
582-
is_webp = ".webp" == extension;
583581
if !RAW_IMAGE_EXTENSIONS.contains(&extension.as_str()) && !IMAGE_RS_EXTENSIONS.contains(&extension.as_str()) && !is_heic {
584582
break 'dir;
585583
}
586584
} else {
587585
break 'dir;
588586
}
589-
let mut pixbuf = if is_heic || is_webp {
590-
let image = if is_heic {
591-
#[cfg(feature = "heif")]
592-
match get_dynamic_image_from_heic(file_name) {
593-
Ok(t) => t,
594-
Err(e) => {
595-
add_text_to_text_view(
596-
text_view_errors,
597-
flg!(
598-
"preview_image_opening_failure",
599-
generate_translation_hashmap(vec![("name", file_name.to_string()), ("reason", e.to_string())])
600-
)
601-
.as_str(),
602-
);
603-
break 'dir;
604-
}
605-
}
606-
607-
#[cfg(not(feature = "heif"))]
608-
panic!("")
609-
} else if is_webp {
610-
match image::open(file_name) {
611-
Ok(t) => t,
612-
Err(e) => {
613-
add_text_to_text_view(
614-
text_view_errors,
615-
flg!(
616-
"preview_image_opening_failure",
617-
generate_translation_hashmap(vec![("name", file_name.to_string()), ("reason", e.to_string())])
618-
)
619-
.as_str(),
620-
);
621-
break 'dir;
622-
}
587+
let mut pixbuf = if cfg!(feature = "heif") && is_heic {
588+
#[cfg(feature = "heif")]
589+
let image = match get_dynamic_image_from_heic(file_name) {
590+
Ok(t) => t,
591+
Err(e) => {
592+
add_text_to_text_view(
593+
text_view_errors,
594+
flg!(
595+
"preview_image_opening_failure",
596+
generate_translation_hashmap(vec![("name", file_name.to_string()), ("reason", e.to_string())])
597+
)
598+
.as_str(),
599+
);
600+
break 'dir;
623601
}
624-
} else {
625-
panic!("");
626602
};
627603

604+
#[cfg(feature = "heif")]
628605
match get_pixbuf_from_dynamic_image(&image) {
629606
Ok(t) => t,
630607
Err(e) => {
@@ -639,6 +616,9 @@ fn show_preview(
639616
break 'dir;
640617
}
641618
}
619+
620+
#[cfg(not(feature = "heif"))]
621+
unreachable!()
642622
} else {
643623
match Pixbuf::from_file(file_name) {
644624
Ok(pixbuf) => pixbuf,

0 commit comments

Comments
 (0)