PNG optimization tools

December 22nd, 2008. Tagged: images, performance

I'm currently experimenting with different tools for optimizing PNG images to figure out strengths/weaknesses of each. Only considering free, ideally open-source, tools that can be run from the command line. For smush.it I just picked pngcrush for no particluar reason and I was thinking that once I have the optimization tool up and running and get the point across that images can be optimized with no human intervention as part of the normal "push" process... then the actual behind-the-scenes png optimizer can be tweaked without affecting the overall workflow.

So, I'm considering these PNG optimizers:

Can you think of any other PNG optimizers out there? Please comment.

Well, I just came back from a cruise with no internet access ($1/minute is unacceptable!) so I used my laptop's idle time to run some of the tools on a bunch of files (well over 10 000 PNG files, smartly collected right before the cruise ;) ).

So far some (very preliminary!) results from running the tools.

  1. pngcrush's -brute option is slower, as expected and usually doesn't help much
  2. pngcrush with -rem alla (strip all chunks only keeping the transparency chunk) doesn't get much better than -rem none (keep all chunks, even useless ones)
  3. pngout seems to give the best results, but it's probably the slowest
  4. pngrewrite is only for pallete PNGs (PNG8), it also seems to convert truecolor PNGs with less than 256 colors to PNG8

Again, these are very preliminary and again, please let me know if you know of any other PNG optimizers.

And keep an eye on the YUIblog's img opt series for more detailed report of the results.

Tell your friends about this post: Facebook, Twitter, Google+

28 Responses

  1. Don’t forget pngquant: http://www.libpng.org/pub/png/apps/pngquant.html

  2. [...] Random Feed wrote an interesting post today onHere’s a quick excerptI’m currently experimenting with different tools for optimizing PNG images to figure out strengths/weaknesses of each. Only considering free, ideally open-source, tools that can be run from the command line. For smush.it I just picked pngcrush for no particluar reason and I was thinking that once I have the optimization tool up and running and get the point across that images can be optimized with no human intervention as part of the normal “push” process… then the actual behind-the-scenes pn [...]

  3. I’ve had the best results most consistently by running PNGs through pngout and then doing a second pass through optipng.

  4. Ryan, I didn’t think pngquant (and pngnq) are in the category of general purpose PNG optimizers, their purpose is to convert truecolor PNGs (with any # of colors) to palette PNG. But I may be wrong… ;)

  5. pngquant optimizes as well as quantizing truecolor PNGs to palette PNGs. If you give it a palette PNG, it’ll just optimize it; if you give it a truecolor PNG, it’ll convert it to palette, then optimize it. In my experience, pngquant is pretty competitive with tools like pngcrush and optipng.

  6. sweet, thanks, will include it in the experiments

  7. You may want to have a look at PNGNQ.

  8. lololol
    what noobs at png compression, especially when most of the programs have been around for sooo long
    Do you guys know anything?
    http://pngnq.sourceforge.net/ to change it to 256 or less colors
    http://entropymine.com/jason/pngrewrite/ to optimize paletted images
    here is the set that does the brunt of work
    http://pmt.sourceforge.net/pngcrush/ pngcrush
    http://advsys.net/ken/utils.htm pngout
    http://optipng.sourceforge.net/ optipng
    http://psydk.org/PngOptimizer.php pngoptimizer WHICH IS OPEN SOURCE, AND YES DOES ACTUALLY HELP ON TOP OF THE OTHERS, don’t be stuck up faggots, I have run intense testing
    and to squeek out a little more
    http://www.walbeehm.com/download/ deflopt
    http://advancemame.sourceforge.net/comp-download.html advpng/advcomp

    combos of any of these work better than any single one, and can achieve faster results than ‘heavy/brute’ methods in any SINGLE one
    Also, I’m not saying I deeply understand pngs, but idk why but order does matter, I made my own png compressor using these other ones, it’s just a batch script with the right options but the order mattered

    If you want best compression and don’t care about time: http://www.jonof.id.au/forum/index.php?topic=846.45 pngslim
    although I got mine to do the same or be off only around 0-20bytes diff and pngslim takes 4-25 times longer than mine

    Seriously if some skiddy online can do it, why can’t some serious programmers that can probably actually understand zlib and libpng by code instead of just by word and made up ideas?

  9. Stoyan there used to be one called ‘gifwizard’ that you could upload to in the 90s. I don’t know what happened to it but the site is now going to something new. I had a look for you but couldn’t find it. However I did find something that was apparently better than it. Quote “InterGif seems to optimise 1%-7% better than GIF Wizard and 11%-34% better than websitegarage.”

    Here is the link for InterGif http://www.chaos.org.uk/~pdh/software/intergif.htm

    Also is there a limit to the amount of images that smushit can do at once? For some reason, it leaves out images that have been attributed to buttons such as search buttons or submit buttons?

  10. Seriously though, if you’re going to do something, do it right. Apply enough research instead of doing ‘good enough’ and stroking your e-peen. Believe me you have alot more work you can do. People that don’t even understand how to program or what to do when they’re missing a dll can do a better job at optimizing images than you ( case in point http://graphicsoptimization.com/ this guy doesn’t know what to do when there’s a missing dll but by god, he knows how to optimize and do it well).
    It’s not even a case of it taking too long either, it’s better to use a different program(not imagemagick) to go from gif to png. I refuse to help more than I already have because I don’t think I’d see any credit coming my or anyone else’s way. The only hints I’ll give is try different programs in different orders, you can have a process that still takes a fraction of the time of large process but can get about 10% smaller files.
    Work smarter, not arrogant unknowing. If a kid can do somethin in 3 months what took the pngslim guy and the ruby png optimizer guys years I think a ‘legit’ programmer like yourself can do much better.
    Hell you should be looking into the open source code cause most of these are and just making a new png optimizer from the ground up using the best methods and ideas from each. duh
    Comment back if you want to talk, the e-mail i listed is spammed to hell and back so I won’t be able to see anything you send

  11. also let my original post through
    censorship is dumb

  12. Thanks Sitelab, I haven’t heard of that one, will give it a shot, thanks!

    lolol, sorry your post didn’t make it through initially, wordpress holds for moderation anything with more than 2 links, I believe. Thanks for the list and the tips, I appreciate it. I did find pngslim (incidentally via a post on graphicsoptimization.com) and have been giving it a some time, looks pretty good, albeit really slow. I don’t think I’ll have the time to start a fresh new PNG opt project, seems like the existing ones are already pretty good and it’s just a question of picking which ones to run depending on “less runtime vs. best results” constraints.

  13. I realised after I posted that it was for gif and not PNG. Sorry!

  14. Sitelab, it’s still appreciated, gifs are next on my agenda for experimentation ;)

  15. [...] 其他压缩工具还有:pngout , optipng , advpng , pngrewrite 。强烈推荐一下pngout,它总能给我带来惊喜,比如一个用pngcrush压缩过的图片(32k),用pngout压缩后还可以在干掉5k!关于这些工具的性能介绍可以阅读 Stoyan Stefanov的另一篇文章PNG optimization tools [...]

  16. hey Stoyan
    just to let you know, png is actually most always smaller than gif I’ve found
    or at least turning gifs into optimized pngs makes them smaller with no quality loss
    only good time to keep a gif a gif, is when it’s really tiny like in the range of 25×25 area

  17. png optimization tools with a script : http://www.css-ig.net/scriptpng

  18. Pngout is powerful if you do hundreds of trials with it using different switches. There’s a shell script out there called pngslim which is perhaps the most powerful png optimization tool available.
    http://graphicsoptimization.com/blog/?p=7

  19. Thanks Zerb, absolutely, PNGSlim rocks for hardcore PNG optimization

  20. ***lolol Says: January 10th, 2009 at 5:28 pm

    (case in point http://graphicsoptimization.com/ this guy doesn’t know what to do when there’s a missing dll but by god, he knows how to optimize and do it well).***

    Ha! Yes, I am only about 1-2 steps above “idiot” status when it comes to the programming side of the house. However, put the right, good tools in my hands and I can generally turn just about anything into a flying tin-can in someone’s web site or GUI (without sacrificing image quality). That’s the thing that amazes me about image optimization. It’s so EASY to do, yet 95+ percent of people out there don’t do it…or think that “save for web” out of Adobe products is the end-all, be-all.

    I’ll leave you with my favorite quote of all-time: “We’re all experts and we’re all idiots…it just depends upon what is being discussed at any given point in time.” Missing DLLs? Idiot. Stripping bits/bytes out of bloated image files? Working my way towards “expert” as best I can. ;-) – Derek

  21. Hello, just a quick note, i do get very very good results with : http://psydk.org/PngOptimizer.php, give it a try, just got better results than pngout with standard options

  22. @Vincent: PngOptimizerCL (the command line version of PngOptimizer) is included with pngslim.

    In my experience, pngslim optimizes the best, nearly all the time, but it’s horribly slow.

    ScriptPNG comes very close to pngslim’s compression, but it’s MUCH faster.

    The latest version of ScriptPNG was released 2010-03-24.

    Two advantages that ScriptPNG has over pngslim are:

    1) it can convert other image file types (bmp, gif, tga, pcs, tif, etc.) to png
    2) it lets you choose from a) fast lossless optimization b) complete lossless optimization c) conversion to paletted PNG without diffusion d) convert to paletted PNG with Floyd-Steinberg diffusion (using pngnq).

    One LARGE disadvantage to ScriptPNG is that the files must reside in the same folder as the script, so you can’t just highlight multiple files and drag and drop them onto the script.

    I’ve been thinking of splitting up the ScriptPNG into 4 scripts (one for each current option) and incorporating drag-n-drop, a la pngslim.

    Usually, I don’t have a pressing time constraint, so I am OK with letting pngslim work in the background on the file(s) I drop onto it. However, it would be nice to get ScriptPNG working in the same manner.

  23. @earthsound : new version of ScriptPNG (2010.03.24 New) is available. Move or copy the ScriptPNG to folder you want, and execute options.

  24. [...] A wide variety of PNG optimization tools which you can run from the command line exist. In the example, I’ve chosen to use OptiPng, but as you will see you can very easily swap it out for a different tool if you desire. Stoyan Stefanov has already done an excellent job outlining how to install each of these optimization tools, so I will simply refer you to his article for installation instructions. [...]

  25. Hello, i’ve found another tool on this website. According to my tests on a lot of pictures, pngxoptimizer was the faster tool and also the better : http://www.css-ig.net/pngxoptimizer.html and it’s free!

  26. youtube video download…

    [...]PNG optimization tools / Stoyan’s phpied.com[...]…

  27. Protip: Optimize those PNGs

    PNGGauntlet incorporates multiple compression algorithms to crush the file sizes as small as possible:

    http://pnggauntlet.com/

    Highly recommended!

  28. […] to fill the void, there’s a great number of tools that excel in writing small PNGs. There are different ways to optimize a […]

Leave a Reply