Tagged as: linux web

PNG is a high-compression lossless image format. PNG has very good compression ratio compared to GIF for many types of images but lots of programs that create PNGs do not compress them as much as they could. If you want to host a website or send images online it is much better to have the smallest images that you can. There are a number of utilities that allow you to correct this problem.

Some of these utilities are:


OptiPNG is a command-line tool to shrink the file size of PNG images. It has a very easy syntax and is easy to learn.

To compress an image called image.png, you would do:

optipng -o7 image.png

This will compress image.png in place and will report how much it has compressed. You can also call it with multiple files to compress, for example you might run this command:

optipng -o7 image1.png image2.png hello/*.png

To optimise image1.png, image2.png and all the PNG images in the hello directory.

OptiPNG can be installed manually from its homepage or you can use the debian and ubuntu repositories to install it:

apt-get install optipng

Rember to be root, or put sudo in front of the command.


PNGCrush is also a command-line tool and is one of the oldest made. It generally gets a higher amount of compression than OptiPNG, although OptiPNG is based upon it. PNGCrush has a slightly more complex syntax and also does not support compressing files in-place so it is not as easy to use.

To compress an image called image.png, you would do:

pngcrush -brute image.png output.png
mv output.png image.png

You have to run images individually with PNGCrush. PNGCrush can be installed manually from its website or you can install it using the repositories in ubuntu and debian:

apt-get install pngcrush

Rember to be root, or put sudo in front of the command.


TinyPNG is a online lossy tool that allows you to compress PNGs to smaller than the lossless tools. Lossy tools compress PNGs by discarding some of the data however when you run your PNG through TinyPNG the effect is really not noticeable.

On TinyPNG there is a file size limit which restricts you to using this for smaller files only - full size photographs will not work on TinyPNG. However, large files and photographs are probably better encoded with JPEG or a similar lossy format.


Optimizilla is another online tool similar to TinyPNG. It offers a good compression ratio but does cause a reduction in the quality of the file.

If you have any questions or improvements, please use our feedback facility.