kornelski / pngquant

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

Support quantization in restricted color space (e.g., to produce ARGB4444 images) #109

Closed annulen closed 10 years ago

annulen commented 10 years ago

Use cases:

Right now I use Gimp script based on [1], adapted to batch processing of images, to quantize them into ARGB444 color space, than I use pngquant if I need to make them indexed (or simply reduce size further). However, [1] uses Floyd-Steinberg and you claim it is not the best dithering algorithm. It's also hard to set up on server (requires whole Gimp + custom script + custom palettes).

[1] http://registry.gimp.org/node/25275

kornelski commented 10 years ago

For ARGB444 use --posterize=4. For RGB565 --posterize=3 will work, but leave one bit of green unused.

annulen commented 10 years ago

Cool! Looks like this option is undocumented.

However, it would be great if pngquant could generate non-indexed images for sake of improved quality. I have an image [1] with color gradients and I'm wondering how much quality can I get from it in ARGB4444. [2] is what I get with Gimp-based solution, and I'm sure that's not the best possible conversion.

[1] http://higgs.rghost.ru/57363540/image.png [2] http://higgs.rghost.ru/57363557/image.png

kornelski commented 10 years ago

The option is in the readme and the manpage. I've updated the built-in help. 554add4dbf1568ac768edcf60a6e4fe6bcdbc989

kornelski commented 10 years ago

In this particular case I'm afraid you won't see improvement with pngquant, because after posterization that image has only 145 colors anyway, so there's nothing to improve in the quantization step.