Beispiel #1
0
 /**
  * {@inheritdoc}
  */
 public function applyEffect(ImageInterface $image)
 {
     list($x, $y) = explode('-', $this->configuration['anchor']);
     $x = image_filter_keyword($x, $image->getWidth(), $this->configuration['width']);
     $y = image_filter_keyword($y, $image->getHeight(), $this->configuration['height']);
     if (!$image->crop($x, $y, $this->configuration['width'], $this->configuration['height'])) {
         $this->logger->error('Image crop failed using the %toolkit toolkit on %path (%mimetype, %dimensions)', array('%toolkit' => $image->getToolkitId(), '%path' => $image->getSource(), '%mimetype' => $image->getMimeType(), '%dimensions' => $image->getWidth() . 'x' . $image->getHeight()));
         return FALSE;
     }
     return TRUE;
 }
 /**
  * {@inheritdoc}
  */
 public function applyEffect(ImageInterface $image)
 {
     $data = [];
     $data['canvas_color'] = $this->configuration['canvas_color'];
     // Get resulting dimensions.
     $dimensions = $this->getDimensions($image->getWidth(), $image->getHeight());
     $data['width'] = $dimensions['width'];
     $data['height'] = $dimensions['height'];
     // Get offset of original image.
     if ($this->configuration['canvas_size'] === 'exact') {
         list($x_pos, $y_pos) = explode('-', $this->configuration['exact']['placement']);
         $data['x_pos'] = image_filter_keyword($x_pos, $data['width'], $image->getWidth()) + $this->configuration['exact']['x_offset'];
         $data['y_pos'] = image_filter_keyword($y_pos, $data['height'], $image->getHeight()) + $this->configuration['exact']['y_offset'];
     } else {
         $data['x_pos'] = $this->configuration['relative']['left'];
         $data['y_pos'] = $this->configuration['relative']['top'];
     }
     // All the math is done, now defer to the toolkit in use.
     return $image->apply('set_canvas', $data);
 }
 /**
  * {@inheritdoc}
  */
 public function applyEffect(ImageInterface $image)
 {
     $watermark_image = $this->imageFactory->get($this->configuration['watermark_image']);
     if (!$watermark_image->isValid()) {
         return FALSE;
     }
     list($x, $y) = explode('-', $this->configuration['placement']);
     $x_pos = image_filter_keyword($x, $image->getWidth(), $watermark_image->getWidth());
     $y_pos = image_filter_keyword($y, $image->getHeight(), $watermark_image->getHeight());
     return $image->apply('watermark', ['x_offset' => $x_pos + $this->configuration['x_offset'], 'y_offset' => $y_pos + $this->configuration['y_offset'], 'opacity' => $this->configuration['opacity'], 'watermark_image' => $watermark_image]);
 }