Optimizing png images with optipng for Google Page Speed

To optimize png images on ubuntu 14.04 we will use optipng.

Installation :

sudo apt-get install optipng

How to use :

optipng /home/user/Image/footer-logo.png -o4

Compression ratio :

Defined by the -oX attribute, where x is a number.

-o0 <=> -o1 -nx -nz
-o1 <=> [use the 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)

You may need to run it with sudo in some cases.

Search in all subfolders :

It is possible to search and optimize all subfolders of a directory. We will search for all png photos and process them with the optimizer.

find /var/www/project.loc/uploads -name *.png -exec optipng -o4 '{}' \;

find - makes it possible to search for files with the desired format in a given directory.

-exec - makes it possible to perform certain manipulations with the found file.

1522 0

Comments

Be the first to review this item. Share your rating and review so that other customers can decide if this is the right item for them.
You have to log in to leave a comment. Sign in

Similar articles