From bb30c1e590c531e12a9a7744f5cea09550407a03 Mon Sep 17 00:00:00 2001 From: Fred Condo Date: Mon, 11 Mar 2013 15:19:09 -0700 Subject: [PATCH] BUG: Preserve alpha channel when cropping This keeps the alpha channel from turning black. --- filesystem/GD.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/filesystem/GD.php b/filesystem/GD.php index d05de83d6..542c25c6b 100644 --- a/filesystem/GD.php +++ b/filesystem/GD.php @@ -264,6 +264,11 @@ class GDBackend extends Object implements Image_Backend { public function crop($top, $left, $width, $height) { $newGD = imagecreatetruecolor($width, $height); + + // Preserve alpha channel between images + imagealphablending($newGD, false); + imagesavealpha($newGD, true); + imagecopyresampled($newGD, $this->gd, 0, 0, $left, $top, $width, $height, $width, $height); $output = clone $this;