VijayaTech Labs Blog

As you all aware that images place an important role in the current generation web but it also brings the issue of dealing with lot of data (bytes in size) between the server and client.For those, there are several types of solutions to implement at various levels like compressing/optimizing image while uploading at client side i.e. in Mobile application or website, Or do that at server level once the image is uploaded into to server.

We are going to know about the second solution i.e. Optimizing images in server.

There two utilities avaialble to optimize image types PNG and JPG/JPEG.


jpegoptim is used to compress JPG/JPEG images.

Below are the steps to install it in Cent OS and how to use it.

Get the installation file into your server from the below source

Create a specific directory to store external utilities or use one if its already present. This step is recommended but not mandatory.

mkdir my_scripts

check the latest version and replace it in the below commands

Get the package


extract it with tar

tar xf jpegoptim-1.4.4.tar.gz

Go to the folder jpegoptim-1.4.4

cd jpegoptim-1.4.4

Execute the Configure file and compile it in the server
Do the below steps.

make strip
make install

export the utility path to PATH variable as below to directly execute jpegoptim utility from anywhere in the server.

export PATH=$PATH”:/my_scripts/jpegoptim-1.4.4″

And execute the below command to compress images using jpegoptim utility. It will search the images with jpeg extension and compress them.

find admin/images/ -name ‘*.jpeg’ -type f -print0 | xargs -0 jpegoptim -o –strip-all

Refer the below URL for more details.


optipng get the latest package from with the path.


Use the below command to install the utility.

rpm -Uvh optipng-0.6.4-1.el6.rf.x86_64.rpm

Go to the folder/directory where png images need to be compressed and issue the following command.

optipng *.png

The above command compresses PNG images.

Refer the below URL for more information on optipng

Share this post with your friends

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top