Sulu\Bundle\MediaBundle\Media\ImageConverter\ImagineImageConverter::getCropParameters PHP Method

getCropParameters() private method

Constructs the parameters for the cropper. Returns null when the image should not be cropped.
private getCropParameters ( Imagine\Image\ImageInterface $image, FormatOptions $formatOptions, array $format ) : array
$image Imagine\Image\ImageInterface
$formatOptions Sulu\Bundle\MediaBundle\Entity\FormatOptions
$format array
return array The crop parameters or null
    private function getCropParameters(ImageInterface $image, $formatOptions, array $format)
    {
        if (isset($formatOptions)) {
            $parameters = ['x' => $formatOptions->getCropX(), 'y' => $formatOptions->getCropY(), 'width' => $formatOptions->getCropWidth(), 'height' => $formatOptions->getCropHeight()];
            if ($this->cropper->isValid($image, $parameters['x'], $parameters['y'], $parameters['width'], $parameters['height'], $format)) {
                return $parameters;
            }
        }
        return;
    }