Magento remove white background color in the product images


In this post is describing how to remove white background color in product images of Magento.This is happening magento is auto resizing images in the image blocks.If you using css styles, you can remove this white color.This is generating using php.

Check this example, you can understand this better.

How can I remove this white background color?

1-Open the app/code/core/Mage/Catalog/Model/Product/Image.php file.

2-Find this script there.You can see it in the line 44.
protected $_backgroundColor = array(255, 255, 255);

3-That color is given by rgb values.You can put your own color by rgb values.For a example if you want to put black color,
protected $_backgroundColor = array(0, 0, 0);

Here is a reference sites to find rgb values of colors.

4-Save the file and clear cache in the admin site using admin panel.Check your images in the front-end.

How can I resize magento product images?

I'm using Magento 1.3 version.

1-Go and open /app/design/frontend/default/default/template/catalog/product/view/media.phtml file.

2-Find the following script in line 73.There is a image tag.

3-Replace the following script.

Note there are width,height and keepFrame(false).

4-Also check the line 50 and 95 in,

Line 33,

5-Save all files, clear magento cache, check your images.If not worked check the correct template you have chosen.Also you can set like resize(375,208) as you wish.


About Author

Sumith Harshan is the Web Engineer Specializes in Java Script, JQuery, HTML4/5, CSS2/3, PHP, CodeIgniter, CakePHP, J2SE, J2EE, XML, Hacking & Security, Mobile Interface Developing, Magento, Wordpress, Joomla, Drupal,PHPBB,Facebook App Developing and Open cart...etc.

  • monu

    hi i have use this code but it change the background only the png images , but the jpeg images are not change the background color . how can i do this .. plz tell me soon

    my email


    Regards Monu Yadav