Ejemplo n.º 1
0
 /**
  * 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;
 }
Ejemplo n.º 2
0
 /**
  * Converts a given entity to its array representation.
  *
  * @param FormatOptions $formatOptions
  *
  * @return array
  */
 private function entityToArray(FormatOptions $formatOptions)
 {
     return ['cropX' => $formatOptions->getCropX(), 'cropY' => $formatOptions->getCropY(), 'cropWidth' => $formatOptions->getCropWidth(), 'cropHeight' => $formatOptions->getCropHeight()];
 }
Ejemplo n.º 3
0
 /**
  * Adds a format-options entity to the file-version.
  *
  * @param FormatOptions $formatOptions
  *
  * @return FileVersion
  */
 public function addFormatOptions(FormatOptions $formatOptions)
 {
     $this->formatOptions[$formatOptions->getFormatKey()] = $formatOptions;
     return $this;
 }