Magento has own resize engine that can resize catalog image on your own desire width and height.That means you can resize image with fixed width and variable height or you can set fixed height with variable width.Also you can resize image with no white background in magento means you remove white background from your image background.So to fit or remove white background use keepFrame(false).

please take a quik look of some functions that I have used in below coding like :
1)constrainOnly :

constrainOnly(bool $flag) : it guarantees that image will not be bigger than it was.we can use it before resize() and default value is true.

2)keepAspectRatio :

keepAspectRatio(bool $flag) : it guarantees that image width/height will not be contorted.we can use it before resize() and default value is true.

3)keepFrame :

keepFrame(bool $flag) : it guarantees that image will have dimension and white background can managed if image is not fit with desired dimention.That means set keepFrame(false) remove the background and set image with desired width/height

for fixed with I have width : 500

for fixed with I have height : 500

Also you can specify the height and width image to image would not exceed that you have mentioned.

You can resize image through Varien_Image if you are using code in custom script or any where else.
I am here checked if there is rsized image or not if not I am creating a new resized image propertioanly with heght and width with Varien_Image.

Sometimes you have only image url like so you want to resize that.For that lets how I am resizing that image.Now I am creating a resized folder and have to save that resized image in that folder.

Resize image with no white background in magento
Tagged on:                             

3 thoughts on “Resize image with no white background in magento

  • June 12, 2015 at 10:49 am

    Thanks Jyotiranjan, for sharing this solution. It’s an easy way to re-size the images with no white background in Magento.

    Check this Background Image Switcher Extension by FME:

    This extension allows you to configure different background images for different events like Christmas, holidays, etc. The images are automatically changed according to the pre-configured store.

  • May 4, 2016 at 9:03 pm

    It is very stupid that every one writing the same code everywhere without telling which file to edit. Guys stop copieng it over and over again

    • May 5, 2016 at 7:59 pm

      I can see you have got totally frustrated.

      Most of time this code implements in list.phtml if you have custom theme with custom package then that file will be at (app/design/frontend/[custom_package]/[custom_theme]/template/catalog/product/) else that file is at by default in (app/design/frontend/base/default/template/catalog/product/) .

      open list.phtml file and check line no near to 50 for list mode and 95 for grid mode.

      The code and logic is described here in blog is for managing image in magento not any other framework. So you can use anywhere in magento for managing images as you like.


Leave a Reply

Your email address will not be published.