1. Bogdan Savluk
  2. yii-image

Commits

Bogdan Savluk  committed 2c669ab

Added watermark method

  • Participants
  • Parent commits db20624
  • Branches default

Comments (0)

Files changed (3)

File Image.php

View file
 
         return $this;
     }
+
+    public function watermark($path, $x, $y){
+        $this->actions['watermark'] = array
+        (
+            'path'=>$path, 'x'=>$x, 'y'=>$y,
+        );
+    }
 } // End Image

File Image_Driver.php

View file
      */
     abstract public function negate($unused);
 
+    abstract public function watermark($params);
 } // End Image Driver

File drivers/Image_GD_Driver.php

View file
         return $img;
     }
 
+    public function watermark($params)
+    {
+        $path = $params['path'];
+        $x = $params['x'];
+        $y = $params['y'];
+        imagealphablending($this->tmp_image, true);
+        imagesavealpha($this->tmp_image, true);
+        $mark = imagecreatefrompng($path);
+        imagecopyresized($this->tmp_image, $mark, $x, $y, 0, 0, imagesx($mark), imagesy($mark), imagesx($mark), imagesy($mark));
+        imagedestroy($mark);
+        return $this->tmp_image;
+    }
 } // End Image GD Driver