Linux, Open Source, Free Software, Bicycles, and other topics of interest.
RSS icon Twitter icon
  • Optipng – Advanced Command Line PNG Image Optimizer

    Posted on July 17th, 2009 linuxandfriends No comments

    Optipng 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 optipng in 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

    -out option 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 optipng on 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

    optipng has 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

    -k option 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

    -o option indicates the levels of optimization. -o5 indicates 5 levels of optimization.

    optipng is a great little command line tool in Linux that can be used to optimize images for web.

    Related Posts

    Comments are closed.