Table of Contents
There is a native tool in MageStack to losslessly optimise images. This means images use less disk space and are served to the customer faster - without losing any quality.
The utility can be accessed by running,
Only a single option (target directory) is required to execute the command. This will run a lossless optimise on images however you can pass the
-l parameter to perform lossy optimisation.
Lossy compression will significantly reduce the space used at the cost of image quality, however the optimiser will intelligently try to minimise the quality reduction.
! It's recommended that you test the image optimisation process on a development or staging copy of your store before running it on live, this will allow you to assess the quality of the process first.
image_optimise.sh [options] [directory]
-l Perform lossy compression on images
directory Directory containing images to optimise
Running a lossless optimise on a single directory
You can optimise your Magento's media directory by passing the path to the script. The script will only optimise un-optimised files and will track the files it has already processed.
Running a lossy optimise on a single directory
Running the optimiser in lossy optimisation mode is as simple as adding the
image_optimise.sh -l /microcloud/domains/example/domains/example.com/http/media
Running optimise on multiple directories
Simply run the command multiple times for each directory,
Running optimise via cron
To optimise files every day at 03:00, run
Then add the following for Lossless compression:
0 3 * * * /microcloud/scripts_ro/image_optimise.sh /microcloud/domains/example/domains/example.com/http/media
Or for Lossy compression:
0 3 * * * /microcloud/scripts_ro/image_optimise.sh -l /microcloud/domains/example/domains/example.com/http/media