Image Optimization and Cleaning

Image Optimization and Cleaning
Magento 1Magento 2
Magento Edition
Pro installation
  • 34
  • 27
  • 5

While working with images in Magento 1, we face several problems:
• Mediocre quality of resized thumbnails due to obvious problems with PHP's GD2-library.
• Size of images is not optimal for search engines due to the presence of meta-data and outdated compression algorithm.
• A huge number of unnecessary files in the 'media' folder that occupy tens, and sometimes hundreds, of gigabytes of space storage.

The first 2 problems are resolved with the help of ImageMagick that replaces a GD2 resize-engine.
As for the trash piles in 'media', this problem is way more complicated. The problem is common for shops with a long length of service. By examining the broad lands of 'media', we came to a conclusion that it represents a kind of archive that stored all images admin users ever uploaded into Magento. Just imagine that! When you as an admin user decide to remove, perhaps, a product or category with images assigned to them or to edit product's 'Images', you expect respective images to turn to dust. But that's not the case! Magento contents itself with the removal of respective DB entries and leaves physical files of the images intact. Well, meet one of the major causes for the website to take up more space storage and to impede system calls for files and images because of a higher load of the file system.

This Magento extension allows you to keep resized thumbnails quality, optimize image size for search engines, and monitor and clean the media folder.


To benefit from the extension's optimization feature that enhances quality and size of images, you need to make sure ImageMagick is installed on your server. You can check that with 'phpinfo();'. Your system administrator can help you install it if needed since he is the one with a root-access.

Under System > Config > SafeMage: Image Optimization and Cleaning > Imagick Optimization, you can enable the extension. Note that 'Resize Mode' and 'Quality' are set to recommended values. By saving the configuration settings, you also trigger 'Flush Catalog Images Cache' to automatically optimize all resized thumbnails in the frontend and make them Photoshop-like.

Cleaning "media"

To keep 'media' clean, the procedure should run periodically, otherwise, the folder will inflate again. Thanks to a built-in cron schedule, this is going to be an easy task. You can make the extension to scan and clean the media folder weekly or monthly. You can select resources to clean and push manual cleaning on the configuration page:
• System > Config > SafeMage: Image Optimization and Cleaning > Image Cleaning

1) Below are the resources available for cleaning:
• Images that do not belong to any product
• Images that do not belong to any category
• DB record related to product's missing image
• DB record related to category's missing image

2) The One-Time Limit for cleaning depends on your server's configuration. Consider lowering the limit if the system hangs for a long period of time

3) Instruct the extension to automatically clean the resources by setting up a cron schedule

4) Click on the 'Clean Now' button to scan and clean unused images immediately

To view cleaning logs, navigate to
• /var/log/cleaned_images.log


  • Provides Photoshop level of quality while resizing all thumbnails in Magento
  • Optimizes size of images for search engines
  • Features ImageMagick engine instead of outdated GD2
  • Removes unused files in '/media/' to reduce the size of the folder
  • Checks physical file <=> its DB record
  • Deletes DB records that relate to missing image files of products and categories
  • Configurable cron schedule for cleaning



Magento CE 1.4.x, 1.5.x, 1.6.x, 1.7.x, 1.8.x, 1.9.x
Magento EE 1.9.x, 1.10.x, 1.11.x, 1.12.x, 1.13.x, 1.14.x


We provide comprehensive product support for all the Magento extensions available on this site starting from the moment of your purchasing them. If you need help on the extensions installation or on any issues relating to our products, our dedicated team of proven technical experts is at your service, ready to assist you at any time.


new feature bugfix
v.1.0.3 (Apr 28, 2020)
Addressed an issue when the placeholder images get removed during cleanup.
v.1.0.2 (Nov 28, 2018)
Improved logging of the optimization procedure.
v.1.0.1 (Mar 7, 2018)
Addressed a ‘chdir: no such directory’ warning.
v.1.0.0 (Feb 19, 2018)
Initial release.


    Pretty good job
    I've just purchased your Magento 1 Image Optimisation and Clean extension to tidy our images up before migrating to Magento 2. In general it looks to have done a pretty good job and has cleaned up 20Gb of orphaned images.
    by Mark May 1, 2020
Write Your Own Review

Only registered users can write reviews. Please, log in or register