-
Notifications
You must be signed in to change notification settings - Fork 84
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
Transparency in PNG is ignored in some cases #186
Comments
Potentially, ImageMagick/ImageMagick#3599 is related. |
I was unable to reproduce this bug when using ImageMagick 7.1.0-37 Q16-HDRI x86_64 b65d0d9af:20220605 |
It looks like this has to do with color reduction and that works different between IM6 and IM7. I am getting consistent results with the following command: |
Why is it different and how? |
PNG has 8-bit transparency. GIF is only binary transparency. So when converting a PNG to GIF the transparency is effectively thresholded to black and white and the partial transparency is lost. |
ImageMagick version
6.9.12-50 Q16 x86_64 17254
libpng 1.6.37
GIF version 87a
Operating system
Linux
Operating system, version and so on
Fedora 35, version 5.17.13-200.fc35.x86_64
Description
Using
convert in.png out.gif
should preserve any transparency in the png (this is especially relevant when dispose=1). This works properly in most cases, but depending on the input png, the background is sometimes incorrectly replaced with (0,0,0). I found a somewhat stable neighborhood of failing inputs, and some very similar inputs that are working properly. Surprisingly, the only difference between the input PNGs that cause imagemagic to fail is pixel data. This points to some failing heuristic or a bug that depends on the input.Example input PNG + output gif, where imagemagic does not preserve transparency:
Example input PNG + output gif, where imagemagic does preserve transparency:
Note that I encountered this bug in the wild several times before filing this bug. The above images were simplified to get closer to a minimal example, but it should be noted that this bug is not just fuzzer territory.
P.S. Imagemagic is amazing, thanks so much for working on it! Let me know if I can provide any additional information.
Steps to Reproduce
For each of the files in "example_images.zip" below:
convert overlay_bad###.png test.gif
yields a gif without proper transparency.convert overlay_good###.png test.gif
yields a gif with proper transparency.Images
Zip with 17 failing images (overlay_bad###.png) and 6 working images (overlay_good###.png):
example_images.zip
The text was updated successfully, but these errors were encountered: