Magento: Get height and width of Image
Image functions are defined in catalog/image helper.
getOriginalWidth gives width of image.
getOriginalHeigh gives height of image. It is not getOriginalHeight(). Spelling mistake from Magento :- )
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
// note that the function is getOriginalHeigh() .. not getOriginalHeight().. spelling mistake from Magento
$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();
Related posts:
- Magento: Get width height of image using Varien_Image class
- Magento: Resize Image
- Magento: Custom function to resize image proportionally
- jQuery: Grey out background and preview image as popup
- Magento: Create Watermark Image
- Magento: How to get top rated products?
- jQuery: Preview Image with Zoom Effect
- Magento: Crop image
- Magento: Rotate image
- How to fix row height in zen-cart product listing?
