PNG (Portable Network Graphics) is one of the most popular image format used over the web – most of the graphics designers uses png format for designing logo of a website or in computer artwork (because PNG is more suitable for computer generated images). Optimizing image is a good practice in modern web development/work because it will allow the pages to load much faster due to reduced image size. Google also recommends all web masters to use optimized images for faster loading of pages and you may already know that SPEED is one of the most important thing to consider while designing a website or a web application.
Now, you understand the importance of optimize image – but there should be a balance between the quality and the size of an image. Loss-less compression is what most people prefer while compressing/optimizing an image. On Linux based operating systems such as Ubuntu, Linux Mint, Fedora, OpenSuse, PCLinuxOS etc you can also use GIMP with save for web plugin to optimize png images (it also supports other popular image formats such as JPG, GIF etc).
GIMP (with image optimizer plugin) is good when you have few image but what you will do if you want to optimize hundreds of png files because because it doesn’t support batch optimization. That’s where the OptiPNG comes in, a great tool to optimize PNG image.
OptiPNG : Advanced PNG optimizer
OptiPNG is a an open source and cross-platform image compression/optimization tool. It supports batch processing i.e you can optimize bulk of png files in one simple command. It is very powerful application, as it provides you a lot of options such as compression level (1-7) where 1 is minimum and 7 is the maximum compression level. Page Speed (by Google Inc) – one of the most popular website optimization plugin/tool, uses OptiPNG for optimizing png files.
How to install OptiPNG
Ubuntu (11.10/12.04/12.10.. or Linux Mint, it should work with any Debian based distributions) users can install it by executing one simple command from terminal (Ctrl+Alt+t) –
sudo apt-get install optipng
Other user can download it from the official website. Primarily it’s a command line tool but front end for various platforms are also available, pretty useful if you don’t want to get your hands dirty with Terminal.
Optimizing Images using OptiPNG
To optimize image you can just give the file name as argument or specify compression level and other options. Just type optipng at terminal to see the help and options available for this tool.
For single image
optipng file_name.png
it will optimize the image and overrite the existing one, with default speed and compression level.
For Higher Compression (obviously the speed will decrease)
optipng -o7 file_name.png
Optimizing all png images of a directory (at higher compression level 7)
cd path_to_image_directory optipng -o7 *.png
Very usefull. Thanks!
Thanks for the tips. You might want to change the last box to read “optipng -o7 *.png” instead of the “-07” as you have it stated.
Thank You! fixed it.
Great post. PNG Optimizer is free tool using you can batch optimize
and reduce the file size of your PNG file images. The reduction in file
size is very useful as it will save Internet bandwidth and hard disk
space. Thanks
I use the find command to process images in subdirectories
find /store/ -iname “*.png” -exec optipng -o7 {} ;
This tool is slow and inefficient.