From: Alexander Meteiko Date: Thu, 15 Jul 2010 15:35:35 +0000 (+0300) Subject: alpha transparencing for IPF_Image_Thumbnail X-Git-Tag: 0.5~354 X-Git-Url: https://git.andy128k.dev/?a=commitdiff_plain;h=40e4d2804d902eefb9f2170a42c10eccf00d05b4;p=ipf.git alpha transparencing for IPF_Image_Thumbnail --- 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,