You are here

protected function Scale::execute in Imagick 8

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 Resize::execute

File

src/Plugin/ImageToolkit/Operation/imagick/Scale.php, line 59

Class

Scale
Defines imagick scale operation.

Namespace

Drupal\imagick\Plugin\ImageToolkit\Operation\imagick

Code

protected function execute(array $arguments = []) {

  // Don't scale if we don't change the dimensions at all.
  if ($arguments['width'] !== $this
    ->getToolkit()
    ->getWidth() || $arguments['height'] !== $this
    ->getToolkit()
    ->getHeight()) {

    // Don't upscale if the option isn't enabled.
    if ($arguments['upscale'] || $arguments['width'] <= $this
      ->getToolkit()
      ->getWidth() && $arguments['height'] <= $this
      ->getToolkit()
      ->getHeight()) {
      return parent::execute($arguments);
    }
  }
  return TRUE;
}