Juicy lil' bytes

How to Maximize PNG Image Compression With advPNG

advPNG is a command line tool that is available as part of the AdvanceCOMP package. In my (admittedly very limited) testing, it had excellent compression ratios for a standard 100x100 pixel, 4x8 bits/pixel, RGB+alpha channel PNG image that was generated in Photoshop CS6 for Mac. Here are the compression level flags that are available so that you can carry out your own testing on the types of image files that you commonly use.


To install the application, download the binary (for Windows users) or source (for Linux / Unix – including Mac OSX users) for the project. If you are installing from source, navigate to the decompressed source directory and use the following commands:

sudo make && sudo make install

This will compile the source to an executable which can be run by typing:


on your command line. For windows users, enter the full path to the .exe file or place the .exe file in a directory on your system PATH so that you can enter the filename and extension without the absolute file path.

My testing was performed with v1.17 of advPNG.

How to Maximize Image Compression

There are four available flags that modify the level of compression that you achieve on the file. The tradeoff for the compression level is the time spent on the compression which can be significant for large image files.

The flags (and their associated descriptions in the advpng --help) are:

Flag Description
-z -1 Compress Fast
-z -2 Compress Normal
-z -3 Compress Extra
-z -4 Compress Extreme


Here are the results for my PNG file that started at 42889 bytes. This file was saved in the default PNG format and was not exported in the Photoshop web format (which notably produces a smaller, already compressed file if you are using Photoshop for your images).

Compression Flag Bytes % Original
-z -1 2344 5.47
-z -2 2339 5.45
-z -3 2275 5.30
-z -4 2167 5.05

Not bad, 5% of the original file size and there wasn’t a significant decrease across the different compression flags with this file. Have a go at it for yourself and see how it works for your files with the applications that you use to generate or modify images. If you have storage space or bandwidth constraints, it may be worth the effort.