How to optimize png image in command line mode

How to optimize png format image in command line mode? The answer is Optipng ,Optipng is a simple and useful tool for optimizing png image runs in command line mode.

Installation:

Optipng has been added to most of Linux distroes' repositories,so install it is very easy :~

Debian/Ubuntu:$ sudo apt-get install optipng
Fedora:# yum install optipng
Archlinux:# pacman -S optipng
Opensuse: YAST->SoftwareManage ,seach "Optipng" and select it.

Example:

I have a png  image names optipng.png  in  my home folder,i  can use below command to optimize it:

$optipng optipng.png

after I optimized the optipng.png,its size turn to 9Kb from 20.2Kb and the image quality is still very good!

optipng1

Usage( easy:) )

optipng [options] files ...
Files:
Image files of type: PNG, BMP, GIF, PNM or TIFF
Basic options:
-h, -help show this help
-v verbose mode / show copyright, version and build info
-o <level> optimization level (0-7) default 2
-i <type> interlace type (0-1) default <input>
-k, -keep keep a backup of the modified files
-q, -quiet quiet mode
Advanced options:
-zc <levels> zlib compression levels (1-9) default 9
-zm <levels> zlib memory levels (1-9) default 8
-zs <strategies> zlib compression strategies (0-3) default 0-3
-zw <window size> zlib window size (32k,16k,8k,4k,2k,1k,512)
-f <filters> PNG delta filters (0-5) default 0,5
-nb no bit depth reduction
-nc no color type reduction
-np no palette reduction
-nz no IDAT recompression (also disable reductions)
-fix enable error recovery
-force write a new output, even if it is larger than the input
-full produce a full report on IDAT (might reduce speed)
-preserve preserve file attributes if possible
-simulate run in simulation mode, do not create output files
-out <file> write output file to <file>
-dir <directory> write output file(s) to <directory>
-log <file> log messages to <file>
-- stop option switch parsing
Optimization level presets:
-o0 <=> -nz
-o1 <=> [apply libpng heuristics] (1 trial)
-o2 <=> -zc9 -zm8 -zs0-3 -f0,5 (8 trials)
-o3 <=> -zc9 -zm8-9 -zs0-3 -f0,5 (16 trials)
-o4 <=> -zc9 -zm8 -zs0-3 -f0-5 (24 trials)
-o5 <=> -zc9 -zm8-9 -zs0-3 -f0-5 (48 trials)
-o6 <=> -zc1-9 -zm8 -zs0-3 -f0-5 (120 trials)
-o7 <=> -zc1-9 -zm8-9 -zs0-3 -f0-5 (240 trials)
Notes:
- The option names are case-insensitive and can be abbreviated.
- Range arguments are cumulative; e.g.
-f0 -f3-5 <=> -f0,3-5
-zs0 -zs1 -zs2-3 <=> -zs0,1,2,3 <=> -zs0-3
- The libpng heuristics consist of:
-o1 <=> -zc9 -zm8 -zs0 -f0 (if PLTE is present)
-o1 <=> -zc9 -zm8 -zs1 -f5 (if PLTE is not present)
- The most exhaustive search -zc1-9 -zm1-9 -zs0-3 -f0-5 (1080 trials)
is offered only as an advanced option, and it is not recomended.
You may implement "man optipng" to see more Optipng's parameters.

Creative Commons License
linuxine.com's blog posts is licensed under a Creative Commons Attribution-Noncommercial-No Derivative Works 3.0 United States License