Home » Magento4 December 2009

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.

Hope it helps. Thanks.


Get New Post by Email

Find me on

FacebookTwitterGoogle+LinkedInRSS Feed
  • Pingback: Magento: Get width height of image using Varien_Image class | Mukesh Chapagain's Blog()

  • Tarnaud


    I follow an other post in order to resize an image in a category as following :

    $imageUrl = Mage::getBaseUrl(‘media’).’catalog/category/’.$child->getResource()->getAttribute(‘logo’)->getFrontend()->getValue($child);

    $imageName = substr(strrchr($imageUrl,”/”),1);

    $imageResized = Mage::getBaseDir(‘media’).DS.”catalog”.DS.”category”.DS.”resized”.DS.”brand-“.$imageName;

    $dirImg = Mage::getBaseDir().str_replace(“/”,DS,strstr($imageUrl,’/media’));

    if (!file_exists($imageResized)&&file_exists($dirImg)) :

    $imageObj = new Varien_Image($dirImg);

    $imageObj->resize(null, 60);



    $newImageUrl = Mage::getBaseUrl(‘media’).”catalog/category/resized/”.”brand-“.$imageName;

    $infos_image = getImageSize($newImageUrl);

    Do you know how i could get the width oh the image resized?

    Thanks in advance.