Magento: Get height and width of Product Image

The following functions can be used to get product’s image height and width. Image functions are defined in Mage_Catalog_Helper_Image class.

getOriginalWidth gives width of image.

getOriginalHeigh or getOriginalHeight gives height of image.

getOriginalSizeArray gives the height and width of an image in array.


$_product = $this->getProduct();

$imageWidth = $this->helper('catalog/image')->init($_product, 'image')->getOriginalWidth();

if($imageWidth > 600) {
    $lightboxImage = $this->helper('catalog/image')->init($_product, 'image')->resize(600);
}
else {
    $lightboxImage = $this->helper('catalog/image')->init($_product, 'image')->__toString();
}

// get height of image

$imageHeight = $this->helper('catalog/image')->init($_product, 'image')->getOriginalHeigh();

// get height width of image in array

$imageHeightWidthArray = $this->helper('catalog/image')->init($_product, 'image')->getOriginalSizeArray();

Hope it helps. Thanks.