I've noticed on our Magento store that when Magento puts product images into cache it's actually making them bigger. I'm not sure where to start debugging this or if there is a fix for it?

To give you an example I uploaded a image which was compressed to 92kb with PhotoShops Save for Web feature. However when I checked the frontend of the website I found that it had increased to 209kb.

The larger version of the file is coming from the Magento cache for product images, it's file path is:


enter image description here

The original file still has the 92kb file size and is located in:


enter image description here

Why & How could Magento be making the file bigger? Also why is it putting the cahed image in a thumbnail directory, all the cached versions of this image are being put in the thumbnail directory, i.e.



Where in the code does Magento process images for the cache?

I've looked in lib/tcpdf/tcpdf.php at $img->setCompressionQuality($this->jpeg_quality);. I've also checked template/catalog/product/view/media.phtml but couldn't find anything.

1 Answer 1


I found where Magento is saving the file, it actually re-saving it with a higher compression/image quality than was used in PS, thus the file is getting bigger. I can fix it but it would mean overriding a Magento core file.

This is the file responsible for increasing the image quality: app/code/core/Mage/Catalog/Model/Product/Image.php

class Mage_Catalog_Model_Product_Image extends Mage_Core_Model_Abstract
    protected $_width;
    protected $_height;
    protected $_quality = 90;

    /** CODE OMMITED **/

     * Set image quality, values in percentage from 0 to 100
     * @param int $quality
     * @return Mage_Catalog_Model_Product_Image
    public function setQuality($quality)
        $this->_quality = $quality;
        return $this;

    /** CODE OMMITED **/

    /** This function resizes the image**/
     * @return Varien_Image
    public function getImageProcessor()
        if( !$this->_processor ) {
//            var_dump($this->_checkMemory());
//            if (!$this->_checkMemory()) {
//                $this->_baseFile = null;
//            }
            $this->_processor = new Varien_Image($this->getBaseFile());
        return $this->_processor;

At the beginning of the file the quality level is hardcoded to 90 and then applied in getImageProcessor(). By commenting out $this->_processor->quality($this->_quality); temporarily I can see that the issue goes away.

Why would Magento do this? This seems like it should be a common issue too. Is the best solution just to create a class override for this core Magento file?


Your Answer

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

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