Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

Black bakground being added to JPEGs only
 
litmusdesigns
Jr. Member
 
Total Posts:  11
Joined:  2008-07-11
 

the resize() function is adding black backgrounds to JPEGs when they are resized.This is on a server using the php5_cgi method of running PHP5. PNGs and GIFs are resized and colored correctly.

I’ve traced this to the _fillBackgroundColor function in /lib/varien/image/adapter/GD2.php but haven’t been able to determine a solution. The background color variable is set properly, but isn’t appyling to JPEGs.  Overriding JPEGs to use imagecreate(), instead of imagecreatetruecolor() creates a properly colored background, but the color quality is unacceptable.

Does anyone know a work around?

Thanks.

 
Magento Community Magento Community
Magento Community
Magento Community
 
litmusdesigns
Jr. Member
 
Total Posts:  11
Joined:  2008-07-11
 

It seems that the imagefill function isn’t working correctly on my hosting account. I found a temp work around by commenting out line 261 (disabling the _fillBackgroundColor func) and adding in an imagefilledrectangle function:

// fill new image with required color
        #$this->_fillBackgroundColor($newImage);
        list($r$g$b) = $this->_backgroundColor;
        
$color imagecolorallocate($newImage$r$g$b);
        
imagefilledrectangle($newImage00134134$color);
Note: this will probably break the transparency in gifs and pngs, so isn’t a long-term fix.

I welcome any suggestions for other possible fixes.

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top