You are here

protected function Scale::execute in ImageMagick 8.3

Same name and namespace in other branches
  1. 8 src/Plugin/ImageToolkit/Operation/imagemagick/Scale.php \Drupal\imagemagick\Plugin\ImageToolkit\Operation\imagemagick\Scale::execute()
  2. 8.2 src/Plugin/ImageToolkit/Operation/imagemagick/Scale.php \Drupal\imagemagick\Plugin\ImageToolkit\Operation\imagemagick\Scale::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 Resize::execute

File

src/Plugin/ImageToolkit/Operation/imagemagick/Scale.php, line 91

Class

Scale
Defines imagemagick Scale operation.

Namespace

Drupal\imagemagick\Plugin\ImageToolkit\Operation\imagemagick

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;
}