Account login

How to compress Magento 2 images and PDF

Magento 2 Image and PDF compression script upload

The Magento image and PDF compression is possible using a script. This script is compatible with all the servers that run PHP, all CMS, it's a standalone installation. It means that you just need to upload a folder of files on your server, then you can start to compress all images and PDF of this server.

Note: Placing the files at the root of you Magento installation is always a good idea because you'll need to browse folders and subfolders after install, to select what is going to be compressed.

Then download + unzip the archive and drop the folder on your server.

Run the installation

You can now call the folder path from your browser typing the URL: www.mywebsite.com/ImageRecycle-Standalone (default name). The install routine will be called, you need to define a password to secure folder access.

Setup your password, it can be anything, nothing related to your Magento install. That should lead you to a success message.

Setup a cron task to make the compression automatic

A Cron task is a scheduled commands or tasks also known as “Cron Jobs" or "crontab".

A Cron URL is available in the script configuration to launch the Magento image and PDF optimization automatically. Depending of the Cron task setup, you can choose when you want launch the compression on your server. For an automatic compression you need to add this URL on your hosting Cpanel, sech for "Cron task" or "Crontab".

Image Metadata, IPTC and Magento compression

The Metadata settings are also available to preserve some of the meta information of your images. For example you may want to preserve location information to use your images with a photo locator module?

Exclude / Include folders from Magento compression

Finally, you need to select where you want to run the optimization, which server folder will be compressed. This is usually at least the Magento product image folders but that can be any folder listed (even from other CMS).

All your server folders under the ImageRecycle install are listed here, click on the name to deploy the folder tree. All new media added in those folders will be checked and listed in the next step for optimization.

Run the Magento image and PDF compression

Here we are, hit the top menu Images to list the optimizable media, if nothing is there hit the button SYNC ALL or try the filter field (top left).

Then use optimize button to check everything is OK, you should be able to compress media and do a "revert to original". The revert option is available only during the media backup time (1 month).

You can also launch a global optimization of your media. It's a background process, so you can close the window, the process will still be executed anyway.