]> git.andy128k.dev Git - ipf.git/commitdiff
alpha transparencing for IPF_Image_Thumbnail
authorAlexander Meteiko <ameteiko@gmail.com>
Thu, 15 Jul 2010 15:35:35 +0000 (18:35 +0300)
committerAlexander Meteiko <ameteiko@gmail.com>
Thu, 15 Jul 2010 15:35:35 +0000 (18:35 +0300)
ipf/image/thumbnail.php

index 46fda1c023aa70f65c8d8eaf4c673dcae5ca4d1e..a651943d8fd9cf7cef351df1a0a289ee994c1cc1 100644 (file)
@@ -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,