Magento Image Compression Solution

by Hendrik Will. 2 Comments

During my last Magento project (Magento Version 1.4.1.0) I noticed the bad image quality of product images in the list view, detail view and also the zoom image. Usually show owners don’t care for loading speed and wanna show their products in high quality instead. Not with high image compression like Magento’s default setting.

The solution is simple if you know where the default setting is hidden:

1. Go to /app/code/core/Mage/Media/Model/File/Image.php
2. Copy Image.php to /app/code/local/Mage/Media/Model/File/Image.php
3. Go to line 174 in your Image.php and change the following code

Old setting with high compression:

$result = imagejpeg($object->getTmpImage(), $object->getFilePath(true), 80);

New setting with almost no compression:

$result = imagejpeg($object->getTmpImage(), $object->getFilePath(true), 100);

In this case 100 means 100% of the image quality. You could also enter 95 or 90 to get a smaller filesize.

4. Save Image.php and upload it to your server
5. Go to your Magento backend System -> Cache Management and clean your image cache and all Magento cache

2 Responses to Magento Image Compression Solution

  1. wik says:

    …or(if you’re ok with pear ;) )


    ./pear channel-discover tinycarts.github.com
    ./pear install tinycarts/Tinycarts_Catalog

    Refresh configuration cache

    System -> Configuration -> General -> Design -> Product Image Extra Settings

    Flush catalog images cache

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>