Returns true iff a crop defined by the crop parameters is valid on
a given image with respect to a given format.
public isValid ( Imagine\Image\ImageInterface $image, integer $x, integer $y, integer $width, integer $height, array $format ) : boolean | ||
$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 |
$height | integer | The height of the crop area |
$format | array | The format definition |
리턴 | boolean |
/** * Constructs the parameters for the cropper. Returns null when * the image should not be cropped. * * @param ImageInterface $image * @param FormatOptions $formatOptions * @param array $format * * @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; }