kornelski / pngquant

Lossy PNG compressor — pngquant command based on libimagequant library
https://pngquant.org
Other
5.25k stars 486 forks source link

Is it possible to keep fully transparent (0 alpha) areas of image fully transparent? #402

Closed Alexander-- closed 1 year ago

Alexander-- commented 1 year ago

I have been fiddling with pngquant (version 3.1.0 from Arch Linux repositories) and noticed, that it sometimes makes fully transparent colors not-so-transparent when told to dramatically reduce number of colors:

pngquant 2 ./ic_unholy_orig.png

Original image: ic_unholy_orig After quantization: ic_unholy_orig-fs8

The new image looks fine at the first glance, but it's second color (the one that fills most of image) actually has alpha value of 1 instead of initial value of 0. This is rather annoying, because the code that checks alpha == 0 for transparent pixels is no longer working as intended.

Can this be fixed?

kornelski commented 1 year ago

Yeah, I think it'd make sense to special-case alpha==0.

kornelski commented 1 year ago

This has been fixed in 7b3819e