If you are a web developer or running a blog then you have to think about your images size and optimization. If you want higher page speed in Google page speed insight tool then you should optimized your .png files before uploading to blog or web server.
There are many optimization tools available for Ubuntu and other Linux distributions but in this post we will use “optipng” tool for this purpose. So follow the steps below to install and optimization the images.
Open terminal via “Ctrl+Alt+T” and go to the image folder location.
To install the optipng
Ubuntu & Other Debian Based Derivatives
sudo apt-get install optipng
If you get “unable to locate error” then first run the command below.
sudo apt-get update
and then above command.
RPM Based Systems
yum install epel-release
Some command for optimization and compression
To optimize and compression single .png image file run this command
Note: image.png is the name of the image file.
To optimize and compression all .png image files inside a folder run this command
To see the file information run
ls -lh image.png
To see the detailed information of the image you can use “pnginfo” tool via command below.
pnginfo -t image.png
If “pnginfo” is no installed then run this command below to install the “pngtools”.
sudo apt-get install pngtools
To keep the backup of the original files then run
optipng -keep image.png
It will create a .bak file in the same folder of all the images.
To know other commands of the “optipng” tool you can run