mujma: Added functions for crop and rotate images. (merged from branches/gsoc)

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@41716 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
Ingo Schommer 2007-09-14 01:48:38 +00:00
parent fcf8302bba
commit a038a20eb5

View File

@ -124,6 +124,25 @@ class GD extends Object {
return $output;
}
function rotate($angle) {
if(!$this->gd) return;
$newGD = imagerotate($this->gd, $angle,0);
$output = new GD();
$output->setGD($newGD);
return $output;
}
function crop($top, $left, $width, $height) {
$newGD = imagecreatetruecolor($width, $height);
imagecopyresampled($newGD, $this->gd, 0, 0, $left, $top, $width, $height, $width, $height);
$output = new GD();
$output->setGD($newGD);
return $output;
}
/**
* Resize an image by width. Preserves aspect ratio.
*/