I have a catalogue of over 10,000 products, and would like to replace the images for the products with compressed versions, is there an extension that will allow me to do this, or an easy way besides doing it product-by-product?

  • are the compressed image names the same name as the origional ones? Jan 25, 2014 at 10:50

2 Answers 2


The question is vague (it was not made clear if you want to resize the resolution or not), but I will give it a shot.

We recently did something similar with our catalog images. There isn't any code that needs to be modified. You just need to run the compression on the files in {base}/media/catalog/product/* Here are some examples:

  • PNG Images: Using OptiPNG: optipng -o7 -strip all media/catalog/product/*.png
  • JPEG Images: Using JPEGTran: find media/catalog/product/ -name "*.jpg" -type f -exec jpegtran -copy none -optimize -outfile {} {} \;
  • GIF Images: Using GIFSicle: gifsicle --batch --optimize=3 media/catalog/product/*.gif

Of course, you might use different settings (especially with JPEG and lossy/lossless compression).

Those commands will rewrite all current images to an optimized version with the same filename. Because you haven't changed the directory or filenames, there is nothing to change in the database or programmatically. Also, since the cache directory is a child of the product directory, all cached images will also be optimized, without the need to refresh any caches.

  • 1
    Is there a way to trigger Magento in doing this by default?
    – snh_nl
    Oct 7, 2014 at 11:16

Since it has been explicitely asked for an extension, I want to add the tinify extension. This extension will compress your images with the TinyPNG / TinyJPG service. It is free up to a certain amount of images and quite reasonable afterwards. There is a M1 and M2 extension on Github:

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.