If you want a faster shop, you have probably looked at Google Pagespeed Insights for useful sugestions. It probably told you to optimize your images. Which means, reducing the size-on-disk without losing quality. This is a very cumbersome process if you do this by hand (opening in Photoshop, saving-as, etcetera). But it is very easy if you use Hypernode. If you follow this article, it will take you only a couple of minutes to set up automatic image optimization.

Thanks to Peter Jaap for doing the initial research (in Dutch).

How much can you win?

First, log in on your Hypernode by SSH and type this command:

Great! It has not changed anything yet, but has calculated that you can save 226MB (or 30%) of disk-usage by optimizing your images.

Saving the optimized images for real

Make sure you have a backup of your media files. Then use this command to replace the old images with the optimized images:

Visit your site, do a CTRL-F5 (Mac: CMD-R) to refresh your cache and visually inspect the results. You will most likely not see a difference, apart from a much quicker page 😉

Exclude directories

To use the hypernode-image-optimizer and exclude one or more directories, specify --exclude with one or more paths. For example:

Recommended: periodic optimization using cron

To keep the disk usage reduced and your shop fast, we recommend you to add a cronjob to optimize new images every night.

NB: Magereport.com checks for a cronjob that optimizes your images periodically. If you optimized your images only once, the check will come out red.

And add this line:

Presto, every night at 4:30 all new images (uploaded the previous day) will be optimized.

Pro tips

The image optimizer will do two things.

First, it will set the image compression level to 90% for JPG images, which is a very safe, conservative value. Many image optimization guides even recommend setting it to 80%. You can do so as well, by running hypernode-image-optimizer --quality 80. See below for samples at different quality levels.

Second, it will shrink big images: 2000+ pixels in width or height. If you want to change the threshold (for example, 3000 pixels), you can use hypernode-image-optimizer --size 2000.

Experimental mode

Since 21 June 2016, an --experimental mode is available. This yields better compression results (notably for PNG) but is slower. Example runs on our test images:

So this is another huge win in size! It takes 2 to 3 times more time, so especially the first run (where all image files are considered) may take a while (e.g. several days if you have hundred thousands of products). This should not be a problem, as the image optimizer runs in the lowest possible priority, so will not disturb your live performance.

As with the regular optimizer, ensure you have a backup before using the experimental mode.

Examples of different quality levels