I have an atlas of assets in a transparent png with 8-bit alpha (660kb) and I want to compress it.

enter image description here

Could you suggest what options do I have? When using a pngquant (I'm using SuperPNG plugin for Photoshop), I'm getting a 58kb file but color is transformed to 8bit palette and there's not enough colors to have smooth gradients (balloons are a good example). The original atlas I'm working with has two times more assets so compression is even more visible...

enter image description here

Is it possible to get something like in-between result? I'd be happy with 150-200kb file with more colors and alpha. Maybe I can use imagemagick with some funny options?

1 Answer 1


pngquant has option to set quality. From pngquant man page

-Q min-max, --quality min-max
              min and max are numbers in range 0 (worst) to 100 (perfect), similar to JPEG.  pngquant will
              use the least amount of colors required to meet or exceed the max quality. If conversion re-
              sults in quality below the min quality the image won't be saved (or if outputting to stdin,
              24-bit original will be output) and pngquant will exit with status code 99

Here is two example with -Q 0 and -Q 100. The file was originally 232 K, used pngcrush to reduce to 224 K (no noticeable improvement).

Lowest quality

pngquant --speed 1 -f --quality 0 --strip pngout.png 8 K

Highest quality

pngquant --speed 1 -f --quality 100 --strip pngout.png 52 K

Also I listed size of all possible output from 0 to 100

for i in {0..100}; do pngquant --speed 1 -f --quality $i --strip pngout.png ; echo "Quality $i " >> pngq.txt ; du -b pngout-fs8.png  >> pngq.txt ; done

--strip option remove some metadata.

Size in Byte

Quality 0 
5644    pngout-fs8.png
Quality 1 
33327   pngout-fs8.png
Quality 2 
41913   pngout-fs8.png
Quality 3 
47641   pngout-fs8.png
Quality 4 
50614   pngout-fs8.png
Quality 5 
51664   pngout-fs8.png
Quality 6 
51771   pngout-fs8.png
Quality 7 
51807   pngout-fs8.png
Quality 8 
51816   pngout-fs8.png
Quality 9 
51797   pngout-fs8.png
Quality 10 
51739   pngout-fs8.png
Quality 11 
51704   pngout-fs8.png
Quality 12 
51729   pngout-fs8.png

Rest all are 5129, so 12 is the maximum level achived. Using optipng, -Q 100 was reduced to 51431 Byte (0.58% reduced)

Further reading ImageMagick: Lossless max compression for PNG? at Stackoverflow.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.