Few hours ago I wrote about image optimization with Jpegoptim. Now I'll write few words about Optipng, a PNG and GIF optimizer.
OptiPNG is a PNG optimizer that re-compresses image files to a smaller size, without losing any information. This program also converts external formats (BMP, GIF, PNM and TIFF) to optimized PNG, and performs PNG integrity checks and corrections. If you wish to learn how PNG optimization works, or to know about other similar tools, see the PNG-Tech article A guide to PNG optimization.
The only drawback of this piece of software is that it saves optimized images only in PNG format, using the same filename. This means you have to replace all references to gif files with png ones (mostly in CSS stylesheets and template files). Another disadvantaje is that sometimes, small gif files are actually smaller in size than the optimized png's, so it's up to you which files you're going to replace.
To parse a whole structure of directories in Linux, you can use the following commands:
Find png files and optimize them:
find -type f -name "*.png" -exec optipng {} \;
Find gif files, optimize and convert them to png:
find -type f -name "*.gif" -exec optipng {} \;
You can use -o(1-7) parameter before brackets, but there's almost no difference between the default value (-o2) and -o7 (slow and hardware intensive).
If you know better tips on how to use OptiPNG please leave a comment below.
Category:
Comments
You can use such parameters:
You can use such parameters:
optipng -nc -nb -o7
The arguments -nc -nb tell optipng not to alter any colour information (or we risk changing the appearance of the optimized image) and -o7 tells it to use the best compression.
If you want compress faster with (little more filesize) than use lower -o value, for example -o5
Thanks for these great tips!
Thanks for these great tips! Will definitely use them!