How to Optimize Images in Magento


Performance of your Magento store plays a crucial part in driving traffic towards your e-commerce website with more and assured conversions. The faster e-commerce website has more conversion ratio than slower websites which ultimately increases your business conversions.

There are many factors which affects the performance of your website and images optimization is one of the important and easy ways to improve the performance of your e-commerce store.

When you visit the website, the server initially calls all of the files of the website to load and depending on the website, the images could take a huge part in all files that need to be loaded. That is the main reason why optimize images are important for the web. The smaller the file’s size of the images, the faster it will be loaded.

So let’s go to the solution now, and find how we can optimize images in Magento.

Images Optimization using SSH

Connect to the server via SSH and install following two utilities for optimizing *.png and *.jpeg files. The optipng utility will be used for optimizing PNG files and to install it, run the following command in your shell.

sudo apt-get install optipng

And for optimizing JPEG files, the jpegoptim utility will be used and to install it, run the following command in your shell.

sudo apt-get install jpegoptim

magento image optimization

As now you have successfully installed the utilities for PNG and JPEG files, let’s start optimization for PNG images inside media/catalog folder of your Magento installation. For this, open the media folder inside the root directory of your Magento installation and execute the following commands. This will find and optimize all the PNG images in all subfolders of the current directory.

cd /var/www/html/magento/skin/frontend/rwd/default
find images/ -iname *.png -print0 |xargs -0 optipng -o7

magento image optimization

To optimize JPEG images, execute the following command, this will find and optimize all the JPEG images in all subfolders of catalog/ directory.

cd /var/www/html/magento/media
find catalog/ -type f -name “*.jpg” -exec jpegoptim –strip-all {} \;

magento image optimization


Images Optimization with Guetzli using SSH

First of all, execute the following commands to install the Guetzli library on your server.

Step.1 sudo apt-get install git gcc make pkg-config libpng-dev

Step.2 git clone

Step.3 cd guetzli

Step.4 make // execute make command in shell

Step.5 sudo cp bin/Release/guetzli /usr/bin/

Now to optimize image using Guetzli, execute the following command.

guetzli –quality 85 col_left_callout.jpg image-out.jpg

That’s it! Fast and effective solution to optimize images on your Magento website in a few minutes.


USA408 365 4638


1301 Shoreway Road, Suite 160,

Belmont, CA 94002

Latest From Our Blog

7 best Website performance test tips to increas...

March 6, 2019
Website Performance and speed are considered major elements that drive user experiences and pave way for business growth, especially in the ecommer...
Read more

Amazon DynamoDB, from development to deployment

March 4, 2019
Amazon DynamoDB is a fully managed proprietary NoSQL database service that supports key-value and document data structures and is offered by Amazon...
Read more

Using LESS in React without Ejecting

February 28, 2019
I recently came across a problem while configuring my React application to use LESS styling. The misleading information on the web made the solutio...
Read more