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

Webp sometimes creates Error: Truncated data detected when parsing chunk payload depending on upstream resizing. #56

Closed
joshchernoff opened this issue Mar 11, 2024 · 3 comments · Fixed by #58

Comments

@joshchernoff
Copy link

joshchernoff commented Mar 11, 2024

Hello 👋

I have this little side project I've been playing with where I build a wasm application from this rust app.
https://github.com/joshchernoff/rusty-image-resizer/blob/web/src/lib.rs

You can see I'm using image's resize_to_fill here https://github.com/joshchernoff/rusty-image-resizer/blob/696b8ef2f182d4deb45dbf074a1c3bd9356c622f/src/lib.rs#L8 and later I write to the cursor with the selected format here
https://github.com/joshchernoff/rusty-image-resizer/blob/696b8ef2f182d4deb45dbf074a1c3bd9356c622f/src/lib.rs#L23

When using image::ImageFormat::WebP sometimes I will produce an error in the image output.

using the -diag option of the webpinfo command https://developers.google.com/speed/webp/docs/webpinfo

I produce

❯ webpinfo -diag /home/somepath/resized-image.webp 
File: /home/somepath/resized-image.webp 
RIFF HEADER:
  File size:  10631
Warning: RIFF size is smaller than the file size.
Error: Truncated data detected when parsing chunk payload.
Errors detected.
There were 1 warning(s).

This happens as a result of the resizing because it only happens at some given sizes where I guess there is a fraction getting dropped on the floor.

The filter also seems to play a role in this issue too.

Thoughts?

@fintelia fintelia transferred this issue from image-rs/image Mar 12, 2024
@joshchernoff
Copy link
Author

I've updated to see the reflected changes.

https://github.com/joshchernoff/rusty-image-resizer/blob/dd64999664a27a773b7e122e14a2e478ac68c9f3/Cargo.toml#L9-L10

I confirmed the hash #3bd5eb2a8c09d

[[package]]
name = "image-webp"
version = "0.1.0"
source = "git+https://github.com/image-rs/image-webp?branch=main#3bd5eb2a8c09dcdcd04c3f7c931e7831e84adb74"
dependencies = [
 "byteorder",
 "thiserror",
]

Though I'm still seeing the

RIFF HEADER:
  File size:  20943
Warning: RIFF size is smaller than the file size.
Error: Truncated data detected when parsing chunk payload.
Errors detected.
There were 1 warning(s).

you can view this yourself at https://greed.observer/rusty-image-resizer/

If you pick webp and nearest and scale to say something like 100x100.

@fintelia
Copy link
Contributor

If you check cargo tree, I think you'll find you actually have two copies of image-webp. One from crates.io and the other from github. Please try:

[patch.crates-io]
image-webp = { git = "https://github.com/image-rs/image-webp", branch = "main" }

@joshchernoff
Copy link
Author

Awesome, thank you 🙏

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

Successfully merging a pull request may close this issue.

2 participants