Closed awused closed 5 months ago
Could you share the code you are using to decode?
In my application I just used image
's into_frames()
method, but for the test run I put this at the end of tests/decode.rs based copying and pasting on the existing tests.
#[test]
fn test_broken() {
let contents = std::fs::read("dog.webp").unwrap();
let mut decoder = image_webp::WebPDecoder::new(Cursor::new(contents)).unwrap();
let (width, height) = decoder.dimensions();
if decoder.is_animated() {
for i in 1..=decoder.num_frames() {
// Decode WebP
let bytes_per_pixel = if decoder.has_alpha() { 4 } else { 3 };
let mut data = vec![0; width as usize * height as usize * bytes_per_pixel];
decoder.read_frame(&mut data).unwrap();
println!("Read frame {i}");
}
}
}
Thanks for reporting this!
This seems to reproduce reliably on any animated gif converted by imagemagick. The animated webps open in other programs or when using the webp-animation crate which wraps libwebp. This is at git head for image-webp where I added a test that just tries to decode every frame of dog.webp.