Optimise Images

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 is required to execute the command,

image_optimise.sh Usage:

image_optimise.sh [directory]

          directory      Directory containing images to optimise


Running 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.

image_optimise.sh /microcloud/domains/example/domains/example.com/http/media

Running optimise on multiple directories

Simply run the command multiple times for each directory,

image_optimise.sh /microcloud/domains/example/domains/example.com/http/media
image_optimise.sh /microcloud/domains/example/domains/example.com/http/skin

Running optimise via cron

To optimise files every day at 03:00, run

crontab -e

Then add,

0 3 * * * /microcloud/scripts_ro/image_optimise.sh /microcloud/domains/example/domains/example.com/http/media

Or do it in a single command like so,

    (crontab -l ; echo "0 3 * * * /microcloud/scripts_ro/image_optimise.sh /microcloud/domains/example/domains/example.com/http/media") | crontab -