示例#1
0
 /**
  * Crops an image based on specified coords and size.
  *
  * You can pass arguments one by one or an array passing arguments
  * however you like.
  *
  * @param  int $x      X position where start to crop.
  * @param  int $y      Y position where start to crop.
  * @param  int $width  New width of the image.
  * @param  int $height New height of the image.
  * @return Image
  */
 public function crop($x, $y = null, $width = null, $height = null)
 {
     list($x, $y, $width, $height) = Normalize::crop($x, $y, $width, $height);
     $crop = $this->imagecreate($width, $height);
     // @codingStandardsIgnoreStart
     imagecopyresampled($crop, $this->image, 0, 0, $x, $y, $width, $height, $width, $height);
     // @codingStandardsIgnoreEnd
     $this->image = $crop;
     $this->updateSize();
     return $this;
 }
示例#2
0
 /**
  * @expectedException Elboletaire\Watimage\Exception\InvalidArgumentException
  */
 public function testCropFail()
 {
     Normalize::crop(23);
 }