-
Optipng – Advanced Command Line PNG Image Optimizer
Posted on July 17th, 2009 No commentsOptipng is a PNG image optimizer that re-compresses image files to a smaller size, without losing any information. This command line program also converts external formats (BMP, GIF, PNM and TIFF) to optimized PNG, and performs PNG integrity checks and corrections.
You can install
optipngin Ubuntu Linux using the following command:$ sudo apt-get install optipng
Usage of optipng
Open a terminal in Ubuntu Linux and type the following command:
$ optipng infile.png -out outfile.png
-outoption is used to pass the name for the optimized image (outfile.png).I did an experiment with two images of different file sizes. One image was 6.5 MB and the other was a small 19.6 Kb. And these are the results I obtained after running
optipngon the two images.File size before File size after % Decrease Large image 6.5 MB 6.3 MB 3.089 % Small image 19.6 KB 16 KB 19.72 % From the table above, we can infer that the smaller the file, the greater is the percentage of compression.
The following are a couple more examples of PNG image optimization using
optipng.Optimize and convert all the files to PNG
optipnghas the ability to convert different image formats to PNG and it does it automatically as shown in the following example.$ optipng -k file1.png file2.tiff file3.gif
-koption ensures that a backup of the original files are retained. Else, the original files will be over written – if they are PNG of course.$ optipng -o5 file1.png file2.tiff file3.gif
-ooption indicates the levels of optimization.-o5indicates 5 levels of optimization.optipngis a great little command line tool in Linux that can be used to optimize images for web.Related Posts
- pngcrush – Image Optimizer for PNG Graphics
- imgopt – PNG And JPEG Image Optimization
- Mogrify – How to resize images from the command line
- Print files with line numbers for each line in Linux
- How to find large files in Linux using command line
