From 4d85666c188b678728501ca0f6781a526c55439c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=95=D0=B2=D0=B3=D0=B5=D0=BD=D0=B8=D0=B9?= Date: Mon, 18 Nov 2013 10:40:39 +0600 Subject: [PATCH] Transparency PNG MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit При использовании функций resize или crop (остальные функции не проверялись) к PNG изображению с прозрачным фоном терялась прозрачность, фон становился черным. --- libraries/Gelato/Image/Image.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/libraries/Gelato/Image/Image.php b/libraries/Gelato/Image/Image.php index b4e5faf..07abc38 100644 --- a/libraries/Gelato/Image/Image.php +++ b/libraries/Gelato/Image/Image.php @@ -218,6 +218,8 @@ class Image // Create a new true color image width new width and height $resized = imagecreatetruecolor($new_width, $new_height); + $transPng = imagecolorallocatealpha($resized, 0, 0, 0, 127); + imagefill($resized, 0, 0, $transPng); // Copy and resize part of an image with resampling imagecopyresampled($resized, $this->image, 0, 0, 0, 0, $new_width, $new_height, $this->width, $this->height); @@ -227,6 +229,8 @@ class Image // Create a new true color image width new width and height $this->image = imagecreatetruecolor($new_width, $new_height); + $transPng = imagecolorallocatealpha($this->image, 0, 0, 0, 127); + imagefill($this->image, 0, 0, $transPng); // Copy and resize part of an image with resampling imagecopyresampled($this->image, $resized, 0, 0, 0, 0, $new_width, $new_height, $new_width, $new_height); @@ -269,6 +273,8 @@ class Image // Create a new true color image $crop = imagecreatetruecolor($width, $height); + $transPng = imagecolorallocatealpha($crop, 0, 0, 0, 127); + imagefill($crop, 0, 0, $transPng); // Copy and resize part of an image with resampling imagecopyresampled($crop, $this->image, 0, 0, $x, $y, $this->width, $this->height, $this->width, $this->height); @@ -278,6 +284,8 @@ class Image // Create a new true color image $this->image = imagecreatetruecolor($width, $height); + $transPng = imagecolorallocatealpha($this->image, 0, 0, 0, 127); + imagefill($this->image, 0, 0, $transPng); // Copy and resize part of an image with resampling imagecopyresampled($this->image, $crop, 0, 0, 0, 0, $width, $height, $width, $height);