Home » Magento

Magento: Get height and width of Image

4 December 2009 1,332 views Popularity: 3% Share/Bookmark

email

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:

  1. Magento: Get width height of image using Varien_Image class
  2. Magento: Resize Image
  3. Magento: Custom function to resize image proportionally
  4. jQuery: Grey out background and preview image as popup
  5. Magento: Create Watermark Image
  6. Magento: How to get top rated products?
  7. jQuery: Preview Image with Zoom Effect
  8. Magento: Crop image
  9. Magento: Rotate image
  10. How to fix row height in zen-cart product listing?
  • http://blog.chapagain.com.np/magento-get-width-height-of-image-using-varien_image-class/ Magento: Get width height of image using Varien_Image class | Mukesh Chapagain’s Blog

    [...] In my previous post on getting height and width of image , I have written focusing on product image,  i.e. getting height and width of product [...]