Sulu\Bundle\MediaBundle\Media\ImageConverter\Cropper\CropperInterface::crop PHP Method

crop() public method

Crops an image according to the given parameters. The crop has to be valid.
public crop ( Imagine\Image\ImageInterface $image, integer $x, integer $y, integer $width, $height ) : Imagine\Image\ImageInterface
$image Imagine\Image\ImageInterface The image to crop
$x integer The x value of the point from where the crop area starts
$y integer The y value of the point from where the crop area starts
$width integer The width of the crop area
return Imagine\Image\ImageInterface
    public function crop(ImageInterface $image, $x, $y, $width, $height);

Usage Example

Example #1
0
 /**
  * Crops a given image according to given parameters.
  *
  * @param ImageInterface $image The image to crop
  * @param array $cropParameters The parameters which define the area to crop
  *
  * @return ImageInterface The cropped image
  */
 private function applyFormatCrop(ImageInterface $image, array $cropParameters)
 {
     return $this->modifyAllLayers($image, function (ImageInterface $layer) use($cropParameters) {
         return $this->cropper->crop($layer, $cropParameters['x'], $cropParameters['y'], $cropParameters['width'], $cropParameters['height']);
     });
 }
CropperInterface