Magento Image Gallery – Getting Resulting Size of Catalog Image Helper Resize Function

galleryimage

I am using the catalog helper resize function like this:

Mage::helper('catalog/image')->init($this->getProduct(), 'image', $before_image->getFile())->keepFrame(false)->constrainOnly(true)->resize(800, 600);

This will return the full image size unless it is larger than 800×600.

When it is larger than 800×600, I need to get the resulting size of the resized image. I have pored over the Mage_Catalog_Helper_Image file and cannot find anything that will give me the resulting size.

Is there any method outside of parsing the resulting URL to locate the cached file on my hard drive to determine the final image dimensions?

Best Answer

What you can do is, take what the method is returning, strip the baseurl from it, so you have the path in /media/ and then use getimagesize

Related Topic