You are here

protected function Crop::execute in ImageMagick 8.3

Same name and namespace in other branches
  1. 8 src/Plugin/ImageToolkit/Operation/imagemagick/Crop.php \Drupal\imagemagick\Plugin\ImageToolkit\Operation\imagemagick\Crop::execute()
  2. 8.2 src/Plugin/ImageToolkit/Operation/imagemagick/Crop.php \Drupal\imagemagick\Plugin\ImageToolkit\Operation\imagemagick\Crop::execute()

Performs the actual manipulation on the image.

Image toolkit operation implementers must implement this method. This method is responsible for actually performing the operation on the image. When this method gets called, the implementer may assume all arguments, also the optional ones, to be available, validated and corrected.

Parameters

array $arguments: An associative array of arguments to be used by the toolkit operation.

Return value

bool TRUE if the operation was performed successfully, FALSE otherwise.

Overrides ImageToolkitOperationBase::execute

File

src/Plugin/ImageToolkit/Operation/imagemagick/Crop.php, line 80

Class

Crop
Defines imagemagick Crop operation.

Namespace

Drupal\imagemagick\Plugin\ImageToolkit\Operation\imagemagick

Code

protected function execute(array $arguments) {

  // Even though the crop effect in Drupal core does not allow for negative
  // offsets, ImageMagick supports them. Also note: if $x and $y are set to
  // NULL then crop will create tiled images so we convert these to ints.
  $this
    ->addArgument(sprintf('-crop %dx%d%+d%+d +repage', $arguments['width'], $arguments['height'], $arguments['x'], $arguments['y']));
  $this
    ->getToolkit()
    ->setWidth($arguments['width'])
    ->setHeight($arguments['height']);
  return TRUE;
}