Can anybody recommend a good method of bulk converting a large amount of PNG-24 files to PNG-8 with as little loss of quality as possible and maintaining transparency?

I've tried ImageMagick but the resulting images weren't quite as crisp quality as I'd like. Using Paint.NET I was able to achieve far better results, but I can't bulk process with this tool as far as I know.

The settings I used with ImageMagick in case there's better options to use: convert file.png -depth 4 file-output.png

I've also been playing with OptiPNG, but I haven't discovered a was of making sure the output images are PNG-8.

4 Answers 4


pngquant is exactly the tool for this. It generates palettes better than ImageMagick.

pngquant --quality=0-90 *.png

This will convert all png files in current directory, and automatically choose number of colors to achieve quality similar to 90%-quality JPEG.

(if it doesn't accept the --quality switch it means you have terribly outdated low-quality version and you should upgrade).

  • 1
    Add --force --ext .png to overwrite the original files.
    – redburn
    Aug 20, 2013 at 11:31
  • I'll compare this against the results of optipng soon and mark one or the other as the answer depending upon a comparison of results.
    – Gavin
    Dec 2, 2015 at 2:03

GIMP does good job optimizing reduced palettes. It has --batch mode and can be scripted. Also has multiple bindings, so you can write for example GIMP script in Python.

  • Thanks vartec - while I was researching how to script GIMP I came across this cool tool as it was mentioned as a plug-in for GIMP (but runs stand-alone) - RIOT
    – Gavin
    Feb 17, 2011 at 20:48

I came across this great tool in my search - RIOT - Radical Image Optimization Tool

Does everything I require and lets you see side-by-side comparison of before and after sample image before you do the batch process.


With the latest versions of RIOT a bug has been introduced that causes some images to be output in greyscale - http://luci.criosweb.ro/riot/bbpress/topic.php?id=471


As a replacement for RIOT I've started using optipng via the following command line to process a whole directory on Windows:

for /r %f in (*.png) do "C:\optipng-0.7.5-win32\optipng.exe" -o3 -strip all "%f"

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .