5

How to resize product image to a perfect rectangle without white spaces at right and left.

At present we are using 1200*1200 size image, and resizing to 450*300

in result we are getting 450*300 image but white space exits

please help us to fix this issue in magento2

We are using this code presently

<?php

$_imagehelper->init($_product, $image)->resize(450, 300);

?>

Thanks in advance

2

set ObjectManager in constructor \Magento\Framework\App\ObjectManager $objectManager;

$imageHelper  = $this->_objectManager->get('\Magento\Catalog\Helper\Image');

$image_url = $imageHelper->init($_product, 'product_page_image_small')->setImageFile($_product->getFile())->resize(450, 300)->getUrl();
1
  • If it works, You can correct the answer as well as up-vote so it will help others. Thanks. Mar 24 '17 at 11:11

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.