Sulu\Bundle\MediaBundle\Media\ImageConverter\Focus\FocusInterface::focus PHP Method

focus() public method

Crops the given image based on a set focus point.
public focus ( Imagine\Image\ImageInterface $image, integer $x, integer $y, integer $width, integer $height ) : Imagine\Image\ImageInterface
$image Imagine\Image\ImageInterface The image to crop
$x integer The x coordinate of the focus point
$y integer The y coordinate of the focuse point
$width integer The desired width of the resulting image
$height integer The desired height of the resulting image
return Imagine\Image\ImageInterface
    public function focus(ImageInterface $image, $x, $y, $width, $height);

Usage Example

Beispiel #1
0
 /**
  * Crops the given image according to the focus point defined in the file version.
  *
  * @param ImageInterface $image
  * @param FileVersion $fileVersion
  * @param array $scale
  *
  * @return ImageInterface
  */
 private function applyFocus(ImageInterface $image, FileVersion $fileVersion, array $scale)
 {
     return $this->modifyAllLayers($image, function (ImageInterface $layer) use($fileVersion, $scale) {
         return $this->focus->focus($layer, $fileVersion->getFocusPointX(), $fileVersion->getFocusPointY(), $scale['x'], $scale['y']);
     });
 }
FocusInterface