imazen / imageflow

High-performance image manipulation for web servers. Includes imageflow_server, imageflow_tool, and libimageflow
https://docs.imageflow.io/
GNU Affero General Public License v3.0
4.14k stars 140 forks source link

Some png files when resized with png.quality results as empty/transparent png file #613

Closed tvatavuk closed 1 year ago

tvatavuk commented 1 year ago

We need to resize this demo.png image.

image

Issue happens with parameters: demo.png?w=1230&h=760&png.quality=75&mode=crop&scale=both

image

If we append png.lossless=true than resized image looks OK, except that we can not control quality demo.png?w=1230&h=760&png.quality=75&mode=crop&scale=both&png.lossless=true

image

Issue happens with code that is using following dependencies:

Same code works as expected with older version of dependencies:

Same issue is tracked here: https://github.com/2sic/2sxc/issues/2932

Please check https://github.com/2sic/2sxc/issues/2932#issuecomment-1315639045

lilith commented 1 year ago

So, I created an integration test on the latest version - but it works on my machine. Can you verify this is the correct input file? Maybe GitHub reencoded it? https://imageflow-resources.s3.us-west-2.amazonaws.com/test_inputs/png_turns_empty.png

Using w=1230&h=760&png.quality=75&mode=crop&scale=both, I get https://imageflow-resources.s3.us-west-2.amazonaws.com/visual_test_checksums/0E5E63543D35A149D.png

lilith commented 1 year ago

Hmm, this is failing on windows but not linux.

lilith commented 1 year ago

And yet even on windows the result looks correct, despite being compressed differently. Can the problem image be emailed to lilith@imazen.io to make sure GitHub isn't 'repairing' it? Also, can you try with the very latest Imageflow release? This was listed as being in an older version.

lilith commented 1 year ago

So, GitHub apparently re-compresses images. The image you e-mailed me is a 24-bit PNG, 18.4KB, and the image GitHub lets me access is a 32-bit PNG, 27.5KB

lilith commented 1 year ago

This was specific to PNG files with a zero alpha channel, encoded when using lossy PNG, and when no transparency-inducing operations are performed. Thank you for e-mailing the problematic file, that allowed me to diagnose the issue.