From ca672552be2162d9a1e4d531178cc0a0de49a197 Mon Sep 17 00:00:00 2001 From: Sophie Herold Date: Thu, 6 Apr 2023 21:45:56 +0200 Subject: [PATCH] decoder: Bring back support for still WebP images We manually have to use the static decoder instead of the frames api as for PNG. Issue #115 --- src/decoder/formats/image_rs_other.rs | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/decoder/formats/image_rs_other.rs b/src/decoder/formats/image_rs_other.rs index 36a75d7..655558f 100644 --- a/src/decoder/formats/image_rs_other.rs +++ b/src/decoder/formats/image_rs_other.rs @@ -125,10 +125,16 @@ impl ImageRsOther { image_rs::codecs::gif::GifDecoder::new(file)?.into_frames(), ImageFormat::AnimatedGif, ), - image_rs::ImageFormat::WebP => ( - image_rs::codecs::webp::WebPDecoder::new(file)?.into_frames(), - ImageFormat::AnimatedWebP, - ), + image_rs::ImageFormat::WebP => { + let decoder = image_rs::codecs::webp::WebPDecoder::new(file)?; + if decoder.has_animation() { + (decoder.into_frames(), ImageFormat::AnimatedWebP) + } else { + // Static WebP images need a different decoder + Self::new_static(path, format, updater, tiles); + return Ok(()); + } + } image_rs::ImageFormat::Png => { let decoder = image_rs::codecs::png::PngDecoder::new(file)?; if decoder.is_apng() {