All posts tagged image processing

Magento: get Height of resized image

For the development of a magento webshop, I needed to return the height of a resized image. There was no standard function to return the resized height. Therefore I used the underneath method to return the height of the resized image.

I first resized the image, and second made a new object of this resized image, this object could return the OrginalHeight of the resized image.

In this way I got the height of the resized image.

 <?php
 $imgUrl = $this->helper('catalog/image')->init($_product, 'small_image')->constrainOnly(TRUE)->keepAspectRatio(TRUE)->keepFrame(FALSE)->resize(280,NULL);
$dirImg = Mage::getBaseDir().str_replace("/",DS,strstr($imgUrl,'/media'));
$imageObj = new Varien_Image($dirImg);
$imgHeight = $imageObj->getOriginalHeight();
 ?>