From 40e4d2804d902eefb9f2170a42c10eccf00d05b4 Mon Sep 17 00:00:00 2001 From: Alexander Meteiko Date: Thu, 15 Jul 2010 18:35:35 +0300 Subject: [PATCH] alpha transparencing for IPF_Image_Thumbnail --- ipf/image/thumbnail.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/ipf/image/thumbnail.php b/ipf/image/thumbnail.php index 46fda1c..a651943 100644 --- a/ipf/image/thumbnail.php +++ b/ipf/image/thumbnail.php @@ -34,7 +34,7 @@ class IPF_Image_Thumbnail { $this->sourceRemove = $sourceRemove; } - public function execute(){ + public function execute($keepTransparency=false){ $ImageInfo = getimagesize($this->Source); if(!$ImageInfo) throw new IPF_Exception_Image(sprintf(__('Cannot open %s image file'), $this->Source)); @@ -82,6 +82,13 @@ class IPF_Image_Thumbnail { $tn = imagecreatetruecolor($this->ThumbnailWidth, $this->ThumbnailHeight); + if ($keepTransparency && $this->SourceType==IMAGETYPE_PNG) + { + imagealphablending($tn, false); + imagefill($tn, 0, 0, imagecolortransparent($tn, imagecolorallocatealpha($tn, 0, 0, 0, 127))); + imagesavealpha($tn, true); + } + imagecopyresampled( $tn, $im, 0, 0, 0, 0, $this->ThumbnailWidth, $this->ThumbnailHeight, -- 2.49.0