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

Zopfli compression in 6.0.0 results in a corrupted image in some cases #449

Closed
bgunnink opened this issue Sep 5, 2022 · 9 comments · Fixed by #450
Closed

Zopfli compression in 6.0.0 results in a corrupted image in some cases #449

bgunnink opened this issue Sep 5, 2022 · 9 comments · Fixed by #450

Comments

@bgunnink
Copy link

bgunnink commented Sep 5, 2022

Using the newly-released 6.0.0 version on Windows 11 (64-bit) on the attached PNG results in the following:

> oxipng -Z -o max cover.png

Processing: cover.png
    2981x2981 pixels, PNG format
    3x8 bits/pixel, RGB
    IDAT size = 6087921 bytes
    File size = 6088031 bytes
Trying: 6 combinations
Found better combination:
    zc = 0  zs = 0  f = 4        5897004 bytes
    IDAT size = 5897004 bytes (190917 bytes decrease)
    file size = 5897114 bytes (190917 bytes = 3.14% decrease)
The resulting image is corrupted and will not be outputted.
This is a bug! Please report it at https://github.com/shssoichiro/oxipng/issues
The resulting image is corrupted

As per instructions, here I am.

The problematic image is available at https://user-images.githubusercontent.com/1986890/188520158-84a1a201-a63f-4884-b880-19980932551b.png

FWIW, I had just successfully compressed this image (same command) with oxipng 5.0.1 a few days ago.

The -o max flag doesn't make a difference, either (same error), but I don't get the error in normal mode (it can't achieve better compression and doesn't even try, I guess).

@Maingron
Copy link

Maingron commented Sep 6, 2022

Noticed the same on Windows 10. Think this only applies to high-resolution images.

@AlexTMjugador
Copy link
Collaborator

AlexTMjugador commented Sep 6, 2022

I'm sorry about the issue. It's caused due to the zopfli version bump to 0.7, which contains a regression that is generating corrupt streams (I can reproduce corruption problems by using the zopfli binary on the attached image). I'll try to dig further in it.

@TPS
Copy link

TPS commented Sep 6, 2022

Is there an issue filed upstream w/ zopfli itself?

@Maingron
Copy link

Maingron commented Sep 6, 2022

For your testing, here are some more images that failed on me. Weirdly it's not applying to all image of the same source.
Failing images for testing (issue 449).zip

Edit: Note that, at least I think so, the images got compressed with an older version, so you might see a 0,00% reduction.

@AlexTMjugador
Copy link
Collaborator

Is there an issue filed upstream w/ zopfli itself?

No, there isn't, but that paperwork is not necessary because I'm a maintainer of that library, and I've just pushed a change that I believe will fix this issue: zopfli-rs/zopfli@fcfb76c.

I'll test the fix with OxiPNG for a bit to confirm that the attached images are working fine now.

@Maingron
Copy link

Maingron commented Sep 7, 2022

If you provide a compiled version, I can run tests too. I got the error on quite many images.

@AlexTMjugador
Copy link
Collaborator

AlexTMjugador commented Sep 7, 2022

Here it is a Windows build of the changes I'm testing. I've cross-compiled it from my Linux workstation and it seems to work well enough to show usage help under Wine: oxipng.zip

Edit: the problematic image attached by the issue poster has just been optimized successfully for me. Other images attached by @Maingron worked fine, too.

@Maingron
Copy link

Maingron commented Sep 7, 2022

@AlexTMjugador didn't get any errors so far. Also tried a 5760x2160 image, although I don't know if that one would have thrown an error.

@AlexTMjugador
Copy link
Collaborator

Thank you all for your input 😄

I've just submitted a PR that should fix the issue.

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.

4 participants