You are here

protected function ScaleAndSmartCrop::execute in Image Effects 8.3

Same name in this branch
  1. 8.3 src/Plugin/ImageToolkit/Operation/gd/ScaleAndSmartCrop.php \Drupal\image_effects\Plugin\ImageToolkit\Operation\gd\ScaleAndSmartCrop::execute()
  2. 8.3 src/Plugin/ImageToolkit/Operation/imagemagick/ScaleAndSmartCrop.php \Drupal\image_effects\Plugin\ImageToolkit\Operation\imagemagick\ScaleAndSmartCrop::execute()
Same name and namespace in other branches
  1. 8 src/Plugin/ImageToolkit/Operation/imagemagick/ScaleAndSmartCrop.php \Drupal\image_effects\Plugin\ImageToolkit\Operation\imagemagick\ScaleAndSmartCrop::execute()
  2. 8.2 src/Plugin/ImageToolkit/Operation/imagemagick/ScaleAndSmartCrop.php \Drupal\image_effects\Plugin\ImageToolkit\Operation\imagemagick\ScaleAndSmartCrop::execute()

File

src/Plugin/ImageToolkit/Operation/imagemagick/ScaleAndSmartCrop.php, line 26

Class

ScaleAndSmartCrop
Defines Imagemagick Scale and Smart Crop operation.

Namespace

Drupal\image_effects\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 $this
        ->getToolkit()
        ->apply('resize', $arguments['resize']) && $this
        ->getToolkit()
        ->apply('smart_crop', $arguments);
    }
  }
  return TRUE;
}