Jul 12, 2012
kalpesh

Magento: Image resize/compression reduces quality of JPEG

In Magento, image quality is distorted when it’s resized in Category page as well as Product page. This is very bad if you are running an eCommerce website because image is the only thing which gives best impression to your customers. There are several complains regarding this in Magento forums with different answers. Some even suggest to use ImageMagick over the default Gd2 library.

If you don’t want to switch to ImageMagick and also don’t want to do much changes, here is a simple solution.

1.) Copy app/code/core/Mage/Catalog/Helper/Image.php
2.) Paste it in local (app/code/local/ , create directories Mage/Catalog/Helper if it’s not there)
So the final structure will be app/code/local/Mage/Catalog/Helper/Image.php
3.) Edit newly pasted Image.php’s init() method, just after it sets “watermark size”, add a line:

$this->setQuality(100);

4.) Save, flush image cache, run any category or product page and see the difference!

Hope this helps!

6 Comments

  • Thanks kalpesh!

    It works for me 🙂

  • Thank you for instructions. Could you please elaborate on exactly where to add this line? I have found several places in image.php where there is a reference to set the watermark size.

  • Can you show us exactly where to paste this?

  • you are the best! thank you!

  • How about PNG photos? Specifically, watermarks? Cause by default it makes it in horrible quality.

    • Hi Dmitrii, it should work as well with the watermarks

Leave a comment

 

Welcome to my Blog

Kalpesh MehtaHelping Magento developers in their day-to-day development problems since 2011. Most of the problems and solutions here are my own experiences while working on different projects. Enjoy the blog and don't forget to throw comments and likes/+1's/tweets on posts you like. Thanks for visiting!

Certifications

Honor

Recognition

Magento top 50 contributors

Magento top 50 contributors

Contributions