示例#1
0
文件: Image.php 项目: sqrt-pro/image
 /** Наложение водяного знака */
 protected function doWatermark($file, $x, $y)
 {
     if (is_null($x)) {
         $x = 'center';
     }
     if (is_null($y)) {
         $y = 'center';
     }
     try {
         $watermark = new Image($file);
     } catch (Ex $e) {
         throw new Ex($e->getMessage(), Ex::WATERMARK);
     }
     $width = $watermark->getWidth();
     $height = $watermark->getHeight();
     list($new_x, $new_y) = static::CalculateOffset($x, $y, $this->getWidth(), $this->getHeight(), $width, $height);
     if (!imagecopy($this->getImage(), $watermark->getImage(), $new_x, $new_y, 0, 0, $width, $height)) {
         Ex::ThrowError(Ex::WATERMARK);
     }
     return $this;
 }
示例#2
0
 /**
  * @dataProvider dataOffset
  */
 function testWatermark($x, $y)
 {
     $img = new Image($this->bike);
     $img->resize(400, 300)->watermark($this->watermark, $x, $y)->save($this->path_to_save . '/watermark_' . $x . '_' . $y . '.jpg');
     $this->markTestSkipped('Нужна визуальная проверка положения водяных знаков');
 }