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

385

Solution 1

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

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

Solution 3

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:
385

Related videos on Youtube

Suzan Cioc
Author by

Suzan Cioc

Updated on September 17, 2022

Comments

  • Suzan Cioc
    Suzan Cioc almost 2 years

    What is returned in getPixels()? I see no information in the doc. How color data is represented? How is it laid out, by row or by column?

  • Gavin
    Gavin over 13 years
    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
  • redburn
    redburn almost 11 years
    Add --force --ext .png to overwrite the original files.
  • Gavin
    Gavin over 8 years
    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.