linux

Online image optimization in Linux:

Image compression may have an interest in many situations. For example, while writing a web article in which we need compressed images to reduce the total weight of a web page. Image compression may also need while sending an email. For this, it is worthwhile to know how to do it quickly from the command line. So here we will see how to lighten images in PNG, JPEG/JPG format with various tools.

PNG images optimization with pngcrush

First, we need to install pngcrush, in Debian we will use the below command:

apt-get install pngcrush

For CentOS and RHEL, use this syntax:

yum install pngcrush

Once installed, pngcrush is very easy to use, for example:

pngcrush -brute -e "compressedimage.png" image_original.png

Here, “-brute” allows us better optimization of the image, “-e” compresses the original image (Note: after specifying “-e” mention the name for the compressed image which will be the output of the tool).

JPEG image optimization with jpegoptim

As similar to pngcrush first we need to install jpegoptim tool. The execution command for Debian:

apt-get install jpegoptim

For CentOS and RHEL machines:

yum install jpegoptim

To use jpegoptim and optimize an image, we simply need to run the following command line:

jpegoptim myimage.jpeg

We can also change the power of the compression with the option “-m” followed by a number from 1 to 100 range. 1 will give a very light image, but with very poor quality. 100 will give a smaller compression but maintains certain quality. So we are the judge to decide what value to put in! Generally, 80 is a good ratio between lightness and image quality.

jpegoptim myimage.jpeg -m 80

Popular Posts You May Read

Explore more hosting insights, tips and industry updates.

An Introduction to web-hosting

Welcome to bodHOST Knowledgebase – your trusted resource for everything related to web hosting. Whether…

How to Redirect a Web Page Using cPanel?

Whether you want to transfer the benefits of your existing domain or just shift a…

Why Choose Cloud Servers from bodHOST?

What is a Cloud Server? The Cloud Computing technology paradigm focuses on offering virtualized resources…