From 2888cf1e7805e04c46310c649e1a6865efbe335e Mon Sep 17 00:00:00 2001 From: Sean Harvey Date: Thu, 4 Mar 2010 01:25:02 +0000 Subject: [PATCH] BUGFIX GD::setQuality() persistence issue because the GD instance is re-created instead of being cloned - thanks Tjofras! git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/branches/2.4@100438 467b73ca-7a2a-4603-9d3b-597d59a354a9 --- filesystem/GD.php | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/filesystem/GD.php b/filesystem/GD.php index 44027915e..ea5451579 100755 --- a/filesystem/GD.php +++ b/filesystem/GD.php @@ -89,8 +89,8 @@ class GD extends Object { } imagecopyresampled($newGD, $this->gd, 0,0, $srcX, $srcY, $width, $height, $srcWidth, $srcHeight); - } - $output = new GD(); + } + $output = clone $this; $output->setGD($newGD); return $output; } @@ -132,7 +132,7 @@ class GD extends Object { imagecopyresampled($newGD, $this->gd, 0,0, 0, 0, $width, $height, $this->width, $this->height); - $output = new GD(); + $output = clone $this; $output->setGD($newGD); return $output; } @@ -148,13 +148,13 @@ class GD extends Object { function rotate($angle) { if(!$this->gd) return; - if(function_exists("imagerotate")) { + if(function_exists("imagerotate")) { $newGD = imagerotate($this->gd, $angle,0); } else { //imagerotate is not included in PHP included in Ubuntu $newGD = $this->rotatePixelByPixel($angle); } - $output = new GD(); + $output = clone $this; $output->setGD($newGD); return $output; } @@ -216,7 +216,7 @@ class GD extends Object { $newGD = imagecreatetruecolor($width, $height); imagecopyresampled($newGD, $this->gd, 0, 0, $left, $top, $width, $height, $width, $height); - $output = new GD(); + $output = clone $this; $output->setGD($newGD); return $output; } @@ -328,8 +328,8 @@ class GD extends Object { } imagecopyresampled($newGD, $this->gd, $destX, $destY, 0, 0, $destWidth, $destHeight, $this->width, $this->height); - } - $output = new GD(); + } + $output = clone $this; $output->setGD($newGD); return $output; } @@ -360,11 +360,8 @@ class GD extends Object { } } - // imagecopyresampled($newGD, $this->gd, 0,0, $srcX, $srcY, $width, $height, $srcWidth, $srcHeight); - - $output = new GD(); + $output = clone $this; $output->setGD($newGD); - if($this->quality) $output->setQuality($this->quality); return $output; }