Resizing via Varien_Image

Posted About 12 years ago. Visible to the public.
$image = new Varien_Image('/full/fs/path/to/image.jpg');

// you cannot use method chaining with Varien_Image
$image->constrainOnly(false);
$image->keepFrame(true);
// avoid black borders by setting background colour
$image->backgroundColor(array(255,255,255));
$image->keepAspectRatio(true);
$image->resize(216, 139);
$image->save('/full/fs/path/to/save/to.jpg');

Mike Whitby
Last edit
Over 10 years ago
Posted by Mike Whitby to Magento (2012-02-03 11:31)