Bulk convert PNG-24 to PNG-8 files with best quality

8

4

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.

Gavin

Posted 2011-02-17T06:55:54.050

Reputation: 275

Answers

6

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).

Kornel

Posted 2011-02-17T06:55:54.050

Reputation: 1 225

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 – 2015-12-02T02:03:24.237

1Add --force --ext .png to overwrite the original files. – redburn – 2013-08-20T11:31:07.613

2

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.

vartec

Posted 2011-02-17T06:55:54.050

Reputation: 740

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 – 2011-02-17T20:48:09.167

1

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.

Update

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

Gavin

Posted 2011-02-17T06:55:54.050

Reputation: 275

0

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"

Gavin

Posted 2011-02-17T06:55:54.050

Reputation: 275