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

Development and Configuration of Order Email Co...

January 9, 2019
    E-commerce businesses always needs dynamic rules of marketing to attract and lure their customers. The more the customers visits the ...
Read more

The Development Steps for Conventional Admin Fo...

December 17, 2018
    The learning curve for Magento 2, with all of the updates, has become even steeper. In this blog, I plan to showcase you how to devel...
Read more

Magento Update Order Data Using Observer

December 3, 2018
    Sometimes we may need to update/change order information like custom_field after an order is placed. We can easily do this on the fly...
Read more