Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

share|improve this question

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.

share|improve this answer
    
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 '11 at 20:48

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

share|improve this answer
1  
Add --force --ext .png to overwrite the original files. – redburn Aug 20 '13 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 '15 at 2:03

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

share|improve this answer

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"
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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