Hi,
I let users upload images through the frontend and I want them to be resized immediately if they are bigger than 800x800.
Now I thought I could use some of SS's methods like 'generateResizedImage()' but I'm a bit stuck with that.
I get the original from the File-table based on an ID.
So I have a 'image' dataobject. Now I want to replace the original with the resized.
What I have already is this:
$photo = DataObject::get_by_id("File", $tip->PhotoID);
$width = $photo->getWidth();
$height = $photo->getHeight();
if($width > $height && $width > 800)
{
$newWidth = 800;
$ratio = $width/$newWidth;
$newHeight = $height/$ratio
}
if($width < $height && $height > 800)
{
$newHeight = 800;
$ratio = $height/$newHeight;
$newWidth = $width/$ratio;
}
if($newWidth && $newHeight)
{
$resized = $photo->generateResizedImage($newWidth, $newHeight);
// do some stuff with the resized.. replace original with resized..?
}
Now there seems to be a parameter missing in the generateResizedImage(???, $width, $height), but there' s nothing about it in the docu:
http://doc.silverstripe.com/assets/classes/default/Image.html#generateResizedImage
I suppose it is $gd, but what is that $gd?
If someone could hint me how to resize the original image using SS that would be great. Otherwise I'm just going to use some plain php...