예제 #1
0
 /** @dataProvider dataLoad */
 function testLoad($image, $width, $height, $type = null)
 {
     $img = new Image();
     $img->load($image);
     $this->assertEquals($width, $img->getWidth(), 'Ширина');
     $this->assertEquals($height, $img->getHeight(), 'Высота');
     $this->assertTrue(is_resource($img->getImage()), 'Ресурс GD');
     $this->assertEquals($type, $img->getType(), 'Тип изображения');
 }
예제 #2
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;
 }