0

I just came across with this very strange problem.

The case: I have these 2 images:

Green dress with gray background Green dress with white background

The images are identical. The only difference is that the 2nd image has a white background.

But when you visit the product's page you can see that the 1st image's colors are blurry while the colors of the 2nd image are correct. (see the Green color)

I did the test with a fresh installation of Magento 1.9.3.1 without any extensions installed. The PHP version is 5.5.9-1ubuntu4.21

I also did the test with an online Magento demo. The results are the same. The green color is blurry.

It has nothing to with the ->setQuality() option. I did a test with $this->helper('catalog/image')->setQuality(100) and the final result is the same. The image that Magento produces has spoiled colors.

Is it a Magento bug, a Zend bug or a PHP bug?

3 Answers 3

1

The image that you provided has a color profile. It seems that Gd2, the image library that magento uses, strips away color profiles during processing, that's why your image looks different.

Related stack overflow question: https://stackoverflow.com/questions/5773032/how-to-stop-gd2-from-washing-away-the-colors-upon-resizing-images

1
  • Indeed, when I exported the images from photoshop "for web and devices" and reuploaded them to Magento the colors where ok. Mar 22, 2017 at 10:33
0

You can check below parameters for your image, check with your tweak and let me know

 <?php echo $this->helper('catalog/image')->init($_product, 'small_image')
    ->keepAspectRatio(true)
    ->keepFrame(true)
    ->keepTransparency(true) 
    ->backgroundColor(array(255,255,255))  
    ->resize($_imgSize)->setQuality(99); ?>
1
  • The parameters don't change the final result. The final image has spoiled colors. Please use the images of my test and do a test of your own. You will be amazed by the results! Mar 20, 2017 at 12:24
0

You need follow code

<?php echo $this->helper('catalog/image')->init($_product, 'small_image')
    ->constrainOnly(true)
    ->keepAspectRatio(false)
    ->keepFrame(FALSE)   
    ->resize($_imgSize); ?>
1
  • I followed the code with xDebug but I can't figure out why the final image has spoiled colors. Please use my test images and perform a test of your own. When you compare the 2 final images you will notice that the colors of the 1st image only are spoiled. Mar 20, 2017 at 12:27

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.