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

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

Closed
annulen opened this issue Aug 8, 2014 · 4 comments

Comments

@annulen
Copy link

annulen commented Aug 8, 2014

Use cases:

  • Sometimes images are used on device which does not support full 32-bit color (e.g., can display only ARGB4444 or RGB565 palette). In this case indexed image with TrueColor, produced by pngquant, might look ugly because of lower color resolution of screen. (Obtaining indexed images is not really important in this case - it's about proper quantization into restricted color space, e.g. 4-bit per channel)
  • Sometimes 8 bit palette is not enough to get desired image quality, but it is desirable to leverage quantization to reduce image size nevertheless.
  • I have one use case where I MUST use indexed 8-bit image with palette color space restricted to 4 bit per channel (if you are wondering what the hell is it, such images are used for hardware cursor image on one obscure platform)

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
Copy link
Owner

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

@annulen
Copy link
Author

annulen commented Aug 8, 2014

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
Copy link
Owner

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

@kornelski
Copy link
Owner

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.

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

No branches or pull requests

2 participants