Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I wanted to give zopfli a try since I have some static .png's that I am using on a website.

I see how I can create .gz and .deflate-files. But how can I create a png that can be displayed in FF, Chrome and Co?

zopfli --i1000 _385.png

The resulting .gz-file is about 4% smaller then the one created with pngCrush (which was about 2% smaller then the original).

share|improve this question

2 Answers 2

Zopfli cannot handle PNG directly.

But you can use ehoeks-zopfli-png:

zopfli --png --i1000 logo.png

You will have to compile it:

git clone https://code.google.com/r/ehoeks-zopfli-png
cd ehoeks-zopfli-png/
make
./zopfli --png --i1000 logo.png

Note that this will only re-compress using the DEFLATE algorithm, you should optimize it first using other tools (OptiPNG, pngout, etc...) and other techniques (a bit off topic here, but check pngquant for smart lossy compression of PNG)

After compressing, you can still optimize it further using tools such as DeflOpt and defluff, but as far as I know this will only save a few bytes.

Another solution, windows-only, is PNGZopli, included in ScriptPNG alongside other tools. And there's also optipng-zopfli (optipng plus zopfli) but I haven't tried it yet.

Update: PNG support is being added in zopfli

share|improve this answer

While you're waiting for tools to integrate it, there is zopfli support in the advancecomp project, which is available in ubuntu and homebrew repos. It provides various compression tools that are independent of its MAME project origins, but the main one of interest is advdef which can recompress the compressed regions of PNG files. An effective workflow is to pass your images through a PNG optimiser such as optipng (to deal with PNG-specific aspects), then through advdef, for example:

optipng -quiet -o2 -nb mypic.png && advdef -z -4 mypic.png

the -4 option tells it to use 'insane' compression levels, i.e. zopfli. The project also includes advpng, but it's not as good as optipng so you're better off using advdef by itself.

A pretty exhaustive comparison of PNG optimisers and recompressors can be found here. It's a shame that TruePNG is Windows only and not open source.

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.