image
image copied to clipboard
Cannot decode a specific WebP image
This happens when decoding the WebP image from https://httpbin.org/image/webp
Expected
It decodes the image successfully
Actual behaviour
Format error decoding WebP: Invalid Chunk header: [0x92, 0x9F, 0x00, 0x9D]
Reproduction steps
Try loading the image from memory like so:
image::load_from_memory_with_format(include_bytes!("PATH_TO_WEBP_FROM_HTTPBIN"), image::ImageFormat::WebP)
.expect("loading webp");
Hello.
I have a problem with webp.
thread '<unnamed>' panicked at 'source slice length (738720) does not match destination slice length (915840)', /home/user/.cargo/registry/src/github.com-1ecc6299db9ec823/image-0.24.2/./src/codecs/webp/extended.rs:458:21
Attempting to open the image that @bradms linked results in this error (0.24.2):
thread 'main' panicked at 'called Result::unwrap()on anErr value: Decoding(DecodingError { format: Exact(WebP), underlying: Some(ChunkHeaderInvalid([146, 159, 0, 157])) })', src/main.rs:2:30
I have the image test-1.dat.zip
and code
use std::{vec, io::{Read, Cursor}, fs::File};
fn main() {
let args = std::env::args().collect::<Vec<_>>();
if args.len() == 1 {
println!("file path unrepresented");
return;
}
let file_path = &args[1];
let mut rdr = File::open(file_path).unwrap();
let mut raw= vec![];
rdr.read_to_end(&mut raw).unwrap();
let image_opt = image::io::Reader::new(Cursor::new(&raw))
.with_guessed_format()
.map_err(image::ImageError::IoError)
.and_then(|rdr| {
rdr.format()
.map(|format| rdr.decode().map(|img| (format, img)))
.transpose()
}).unwrap();
if let Some((format, _img)) = image_opt {
println!("image format: {:?}", format);
} else {
print!("Unknown image format");
}
}
output
thread 'main' panicked at 'source slice length (94128) does not match destination slice length (142884)', /home/user/.cargo/registry/src/github.com-1ecc6299db9ec823/image-0.24.2/./src/codecs/webp/extended.rs:458:21
stack backtrace:
0: rust_begin_unwind
at /rustc/7737e0b5c4103216d6fd8cf941b7ab9bdbaace7c/library/std/src/panicking.rs:584:5
1: core::panicking::panic_fmt
at /rustc/7737e0b5c4103216d6fd8cf941b7ab9bdbaace7c/library/core/src/panicking.rs:143:14
2: core::slice::<impl [T]>::copy_from_slice::len_mismatch_fail
at /rustc/7737e0b5c4103216d6fd8cf941b7ab9bdbaace7c/library/core/src/slice/mod.rs:3161:13
3: core::slice::<impl [T]>::copy_from_slice
at /rustc/7737e0b5c4103216d6fd8cf941b7ab9bdbaace7c/library/core/src/slice/mod.rs:3168:13
4: image::codecs::webp::extended::WebPStatic::fill_buf
at /home/user/.cargo/registry/src/github.com-1ecc6299db9ec823/image-0.24.2/./src/codecs/webp/extended.rs:458:17
5: image::codecs::webp::extended::ExtendedImage::fill_buf
at /home/user/.cargo/registry/src/github.com-1ecc6299db9ec823/image-0.24.2/./src/codecs/webp/extended.rs:311:17
6: <image::codecs::webp::decoder::WebPDecoder<R> as image::image::ImageDecoder>::read_image
at /home/user/.cargo/registry/src/github.com-1ecc6299db9ec823/image-0.24.2/./src/codecs/webp/decoder.rs:325:17
7: image::image::decoder_to_vec
at /home/user/.cargo/registry/src/github.com-1ecc6299db9ec823/image-0.24.2/./src/image.rs:585:5
8: image::dynimage::decoder_to_image
at /home/user/.cargo/registry/src/github.com-1ecc6299db9ec823/image-0.24.2/./src/dynimage.rs:1020:23
9: image::dynimage::DynamicImage::from_decoder
at /home/user/.cargo/registry/src/github.com-1ecc6299db9ec823/image-0.24.2/./src/dynimage.rs:175:9
10: <image::io::free_functions::load_inner::LoadVisitor as image::io::free_functions::DecoderVisitor>::visit_decoder
at /home/user/.cargo/registry/src/github.com-1ecc6299db9ec823/image-0.24.2/./src/io/free_functions.rs:106:13
11: image::io::free_functions::load_decoder
at /home/user/.cargo/registry/src/github.com-1ecc6299db9ec823/image-0.24.2/./src/io/free_functions.rs:62:37
12: image::io::free_functions::load_inner
at /home/user/.cargo/registry/src/github.com-1ecc6299db9ec823/image-0.24.2/./src/io/free_functions.rs:110:5
13: image::io::reader::Reader<R>::decode
at /home/user/.cargo/registry/src/github.com-1ecc6299db9ec823/image-0.24.2/./src/io/reader.rs:228:9
14: test_webp::main::{{closure}}::{{closure}}
at ./src/main.rs:20:35
15: core::option::Option<T>::map
at /rustc/7737e0b5c4103216d6fd8cf941b7ab9bdbaace7c/library/core/src/option.rs:906:29
16: test_webp::main::{{closure}}
at ./src/main.rs:19:17
17: core::result::Result<T,E>::and_then
at /rustc/7737e0b5c4103216d6fd8cf941b7ab9bdbaace7c/library/core/src/result.rs:1311:22
18: test_webp::main
at ./src/main.rs:15:21
19: core::ops::function::FnOnce::call_once
at /rustc/7737e0b5c4103216d6fd8cf941b7ab9bdbaace7c/library/core/src/ops/function.rs:227:5
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
Image can't handle odd-sized images. https://github.com/image-rs/image/issues/1647 Which is kind of a joke in this day and age.
Webp worked perfectly with libwebp-image that uses non-rust impl.
It seems that there are two separate issues being described here.
- An invalid chunk header error
- An unrelated "slice length" panic
~~Maybe #1779 shouldn't have been closed?~~
~~Here's another reproducer for the second issue: bevy_mod_paramap.webp.zip~~
edit: my particular reproducer was fixed by #1806.
While my reproducer for the "slice length" panic and the one from #1799 were both seemingly fixed by #1806, https://github.com/image-rs/image/issues/1712#issuecomment-1127393893 seems to be a separate issue that is still present in the latest commit.
I can confirm that the problem reported by @ava57r persists
Using this https://cdn.7tv.app/emote/638767f24cc489ef45239272/4x.webp image results in panicked at 'source slice length (43008) does not match destination slice length (65536)'
This is now fixed, I believe thanks to https://github.com/image-rs/image/pull/1959