From d10858bb6603f033a986607c02fce1e2b170aa1d Mon Sep 17 00:00:00 2001 From: Oliver Vogel Date: Wed, 16 Apr 2014 20:03:22 +0200 Subject: [PATCH] bugfix --- src/Intervention/Image/Image.php | 3 +++ tests/ImageTest.php | 9 +++++++++ 2 files changed, 12 insertions(+) diff --git a/src/Intervention/Image/Image.php b/src/Intervention/Image/Image.php index 53f3081d..b7b3e50a 100644 --- a/src/Intervention/Image/Image.php +++ b/src/Intervention/Image/Image.php @@ -1868,6 +1868,9 @@ class Image private function cloneResource($resource) { $clone = imagecreatetruecolor($this->width, $this->height); + imagealphablending($clone, false); + imagesavealpha($clone, true); + imagecopy($clone, $resource, 0, 0, 0, 0, $this->width, $this->height); return $clone; diff --git a/tests/ImageTest.php b/tests/ImageTest.php index ea7d6b05..ac145f86 100644 --- a/tests/ImageTest.php +++ b/tests/ImageTest.php @@ -1489,6 +1489,15 @@ class ImageTest extends PHPUnit_Framework_Testcase $this->assertEquals('#00ff00', $img->pickColor(0, 0, 'hex')); } + public function testBackupKeepTransparency($value='') + { + $img = new Image('public/circle.png'); + $img->backup(); + $img->reset(); + $transparent = array('r' => 0, 'g' => 0, 'b' => 0, 'a' => 0.0); + $this->assertEquals($transparent, $img->pickColor(0, 0, 'array')); + } + public function testLimitColors() { // reduce colors