5 use \Intervention\Image\Point;
6 use \Intervention\Image\Size;
18 $width = $this->
argument(0)->type(
'digit')->required()->value();
19 $height = $this->
argument(1)->type(
'digit')->required()->value();
20 $x = $this->
argument(2)->type(
'digit')->value();
21 $y = $this->
argument(3)->type(
'digit')->value();
23 if (is_null($width) || is_null($height)) {
24 throw new \Intervention\Image\Exception\InvalidArgumentException(
25 "Width and height of cutout needs to be defined."
29 $cropped =
new Size($width, $height);
30 $position =
new Point($x, $y);
33 if (is_null($x) && is_null($y)) {
34 $position = $image->getSize()->align(
'center')->relativePosition($cropped->align(
'center'));
38 $image->getCore()->cropImage($cropped->width, $cropped->height, $position->x, $position->y);
39 $image->getCore()->setImagePage(0,0,0,0);