You are here

Crop.php in Imagick 8

File

src/Plugin/ImageToolkit/Operation/imagick/Crop.php
View source
<?php

namespace Drupal\imagick\Plugin\ImageToolkit\Operation\imagick;

use Drupal\system\Plugin\ImageToolkit\Operation\gd\Crop as GdCrop;
use Imagick;

/**
 * Defines imagick crop operation.
 *
 * @ImageToolkitOperation(
 *   id = "imagick_crop",
 *   toolkit = "imagick",
 *   operation = "crop",
 *   label = @Translation("Crop"),
 *   description = @Translation("Crops an image to the given dimensions (ignoring aspect ratio).")
 * )
 */
class Crop extends GdCrop {
  use ImagickOperationTrait;

  /**
   * {@inheritdoc}
   */
  protected function process(Imagick $resource, array $arguments) {
    $success = $resource
      ->cropImage($arguments['width'], $arguments['height'], $arguments['x'], $arguments['y']);
    $resource
      ->setImagePage($arguments['width'], $arguments['height'], 0, 0);
    return $success;
  }

}

Classes

Namesort descending Description
Crop Defines imagick crop operation.