Hi,
I'm looking for a way to scale an image proportionally, filling a given width and height.
Scaling can not get smaller than the dimensions given.
After downscaling the image, i wont it cropped from center, so the dimension that goes beyond the given size is cropped away.
See explanation and PHP code here: http://911-need-code-help.blogspot.dk/2009/04/crop-to-fit-image-using-aspphp.html
My question is, can someone show me how to implement the above in SilverStripe, i think it should be done using a class that extends DataObjectDecorator, so it can be easily moved between projects.
Example found on the forums using DataObjectDecorator:
http://www.silverstripe.org/template-questions/show/16398#post301340
class CustomImage extends DataObjectDecorator {
function Optimised($width, $height) {
return $this->owner->getFormattedImage('Optimised', $width, $height);
}
function generateOptimised(GD $gd, $width, $height) {
$gd->setQuality(70);
return $gd->croppedResize($width, $height);
}
}
Thank you!