3

my new generated product thumbnails have a black instead of a white background, but i dind't change anything. How can i change settings like that? i tried settings the background image with the helper function but that didn't help...

Mage::helper('catalog/image')->init($product, 'thumbnail', $image->getFile())->backgroundColor(255, 255, 255)->resize(400)

EDIT

It is very confusing... The Problem doesn't exist on any image. I attached two images of a product. The 1st image gets a white and the 2nd a black background. Here's my source code to receive the thumbnails in the template /catalog/product/view/media.phtml:

foreach ($this->getGalleryImages() as $_image) { $this->helper('catalog/image')->init($this->getProduct(), 'thumbnail', $_image->getFile())->resize(301); }

If i add a background color of red like the following, only the 1st image will get that. The 2nd image is still black.

$this->helper('catalog/image')->init($this->getProduct(), 'thumbnail', $_image->getFile())->backgroundColor(array(255, 0, 0))->resize(301);

The magento version is 1.8.1. I tried that images in a magento installation with the version 1.9.1 where the problem doesn't exist...

Thanks for any help!

white background black background

2

You need to check for the parent div stylings, the image it self has white background but it seems that the problem is from the parent div. Use Firebug or Chrome's developer tools for troubleshooting the reason of the problem.


Update:

Go with this:

Mage::helper('catalog/image')->init($product, 'thumbnail', $image->getFile())->backgroundColor(array(255, 255, 255))->resize(400)
  • The black background is definitly in the image file – barannd Jul 17 '14 at 9:13
  • @user12272 Answer updated – Michel Gokan Jul 17 '14 at 9:43
  • Doesn't change anything. If it is a string, the method converts it into an array... if (!is_array($colorRGB)) { $colorRGB = func_get_args(); } – barannd Jul 17 '14 at 15:01
0

Save one of those images to your desktop. Then open it in photoshop and check if that background color is part of the image or not. If it's part of the image, changing the background CSS won't do any good. In that case the image height x width dimensions don't fit exactly in the settings for the thumbnail, and the rest of the image is filled with a background color.

We've had this one time, only with white backgrounds. It turned out to be one class that extended another class that created the images and somehow changed the background. I can't say what class it is - this is just a hint so you can check this is the case or not.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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