Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot decode a specific WebP image #1712

Closed
svercl opened this issue May 9, 2022 · 8 comments
Closed

Cannot decode a specific WebP image #1712

svercl opened this issue May 9, 2022 · 8 comments

Comments

@svercl
Copy link

svercl commented May 9, 2022

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");
@svercl svercl closed this as completed May 9, 2022
@svercl svercl reopened this May 9, 2022
@ava57r
Copy link

ava57r commented May 14, 2022

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

@ghost
Copy link

ghost commented May 14, 2022

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

@ava57r
Copy link

ava57r commented May 16, 2022

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.

@installgentoo
Copy link
Contributor

Image can't handle odd-sized images. #1647
Which is kind of a joke in this day and age.

Webp worked perfectly with libwebp-image that uses non-rust impl.

@rparrett
Copy link

rparrett commented Jan 18, 2023

It seems that there are two separate issues being described here.

  1. An invalid chunk header error
  2. 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.

@rparrett
Copy link

rparrett commented Jan 18, 2023

While my reproducer for the "slice length" panic and the one from #1799 were both seemingly fixed by #1806, #1712 (comment) seems to be a separate issue that is still present in the latest commit.

@muniategui
Copy link

muniategui commented Jun 21, 2023

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)'

@fintelia
Copy link
Contributor

This is now fixed, I believe thanks to #1959

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants