Resizing images that are too big or too small for the product pages, en-masse

Last modified by Discovery on Thu, June 24, 2010 16:58
Source|Old Revisions  

This is an old revision of the document!

Speed up tip, time required 5 minutes + CPU time.

So you have uploaded lots of images without realising exactly how large they are. You load up a product page on a customer’s PC and the nice and zoomable image doesn’t behave as well as it did on your own PC. What to do?

In the linux shell go into media/catalog/product and see how many images are BIG. How big is big? You decide. This depends on what products you are selling, but when they are in the hundreds of kilobytes then page response is not going to be snappy:

find . -type f -size +150k -print|wc

That will show how many are over 150Kb. Unless you have very big thumbnails this is not going to retrieve a list of them, just the full images.

Now to resize them en-masse:

find . -name ‘*.jpg’ -size +150k -exec mogrify -resize 640 {} ;

As Bill Gates once said, 640 pixels is big enough for anyone...

That will resize the 150k images to 640 pixels wide and keep them in proportion. 640 pixels gives the 2x+ zoom and will not overwhelm the browser.

If you do have specific images you want larger than that then you can reload them for those specific products or set your mogrified image size accordingly, maybe to only work on bigger images.

There is no need to rebuild the image cache after applying the above technique, obviously you can put other parameters into the mogrify command to set jpg quality should the default results not be good enough. You can also tar cvf the images beforehand just in case you want to roll back a quality level.


Magento 2 GitHub Repository

Magento Job Board - Some sort of tag line goes here

Latest Posts| View all Jobs