示例#1
0
 protected function _watermark($filename, $position, $padding = 5)
 {
     $values = parent::_watermark($filename, $position, $padding);
     if ($values == false) {
         throw new \InvalidArgumentException("Watermark image not found or invalid filetype.");
     } else {
         extract($values);
         $wsizes = $this->sizes($filename);
         $sizes = $this->sizes();
         // Load the watermark preserving transparency
         $watermark = $this->load($filename, true);
         // Below is to prevent glitch in GD with negative  $x coords
         if ($x < 0 || $y < 0) {
             $this->debug("Modifying watermark to remove negative coords.");
             // Generate a new width and height for the watermark.
             $newwidth = $x < 0 ? $wsizes->width + $x : $wsizes->width;
             $newheight = $y < 0 ? $wsizes->height + $y : $wsizes->height;
             // Create a transparent image the size of the new watermark.
             $tmpwatermark = $this->create_transparent_image($newwidth, $newheight);
             $this->debug("New size is {$newwidth} x {$newheight} and coords are {$x} , {$y}");
             // Call the resize function based on image format
             imagecopy($tmpwatermark, $watermark, 0, 0, $x < 0 ? abs($x) : 0, $y < 0 ? abs($y) : 0, $newwidth, $newheight);
             // Set the variables for the image_merge
             $watermark = $tmpwatermark;
             $x = $x < 0 ? 0 : $x;
             $y = $y < 0 ? 0 : $y;
         }
         // Used as a workaround for lack of alpha support in imagecopymerge.
         $this->debug("Coords for watermark are {$x} , {$y}");
         $this->image_merge($this->image_data, $watermark, $x, $y, $this->config['watermark_alpha']);
     }
 }
示例#2
0
文件: imagick.php 项目: wushian/MDD
 protected function _watermark($filename, $position, $padding = 5)
 {
     extract(parent::_watermark($filename, $position, $padding));
     $wmimage = new \Imagick();
     $wmimage->readImage($filename);
     $wmimage->evaluateImage(\Imagick::EVALUATE_MULTIPLY, $this->config['watermark_alpha'] / 100, \Imagick::CHANNEL_ALPHA);
     $this->imagick->compositeImage($wmimage, \Imagick::COMPOSITE_DEFAULT, $x, $y);
 }
示例#3
0
 protected function _watermark($filename, $position, $padding = 5)
 {
     extract(parent::_watermark($filename, $position, $padding));
     $wmimage = new \Imagick();
     $wmimage->readImage($filename);
     $wmimage->setImageOpacity($this->config['watermark_alpha'] / 100);
     $this->imagick->compositeImage($wmimage, \Imagick::COMPOSITE_DEFAULT, $x, $y);
 }
 protected function _watermark($filename, $position, $padding = 5)
 {
     extract(parent::_watermark($filename, $x, $y));
     $image = '"' . $this->image_temp . '"';
     $filename = '"' . $filename . '"';
     $x >= 0 and $x = '+' . $x;
     $y >= 0 and $y = '+' . $y;
     $this->exec('composite', '-compose atop -geometry ' . $x . $y . ' ' . '-dissolve ' . $this->config['watermark_alpha'] . '% ' . $filename . ' ' . $image . ' ' . $image);
 }
 protected function _watermark($filename, $position, $padding = 5)
 {
     $values = parent::_watermark($filename, $position, $padding);
     if ($values == false) {
         throw new \InvalidArgumentException("Watermark image not found or invalid filetype.");
     }
     extract($values);
     $x >= 0 and $x = '+' . $x;
     $y >= 0 and $y = '+' . $y;
     $this->exec('composite', '-compose atop -geometry ' . $x . $y . ' ' . '-dissolve ' . $this->config['watermark_alpha'] . '% ' . '"' . $filename . '" "' . $this->image_temp . '" ' . $image);
 }