Image resize (thumb image) keeps the aspect ratio

Permalink
Hi,

I am looking for a simple solution that keeps the aspect ration on getThumbnail() function.

$ih = Loader::helper('image');
$thumb = $ih->getThumbnail($image, 307, ?);

In this case I only need to re-size width, the height will automatically re-sized based on the aspect ratio.

Looking for the expert helps.

Thanks,

rajeshpuliyoor
 
aghouseh replied on at Permalink Reply
aghouseh
I was originally just specifying a null value for the other axis, but that throws a division by zero error on the initial generation of the thumbnail. As of now, it looks like the simplest way to do this effectively is to set an arbitrarily high number for the other axis value (we decided that 10000 should be sufficient!), and that way it would effectively never be constrained by that dimension.

$ih = Loader::helper('image');
$thumb = $ih->getThumbnail($image, 307, 10000);


Hope this helps!