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?
2 Answers
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