You are here

protected function AdvanceResize::validateArguments in image effect 1.0.x

Same name in this branch
  1. 1.0.x src/Plugin/ImageToolkit/Operation/gd/AdvanceResize.php \Drupal\image_effect\Plugin\ImageToolkit\Operation\gd\AdvanceResize::validateArguments()
  2. 1.0.x src/Plugin/ImageToolkit/Operation/imagick/AdvanceResize.php \Drupal\image_effect\Plugin\ImageToolkit\Operation\imagick\AdvanceResize::validateArguments()
Same name and namespace in other branches
  1. 8 src/Plugin/ImageToolkit/Operation/imagick/AdvanceResize.php \Drupal\image_effect\Plugin\ImageToolkit\Operation\imagick\AdvanceResize::validateArguments()
  2. 2.0.x src/Plugin/ImageToolkit/Operation/imagick/AdvanceResize.php \Drupal\image_effect\Plugin\ImageToolkit\Operation\imagick\AdvanceResize::validateArguments()

File

src/Plugin/ImageToolkit/Operation/imagick/AdvanceResize.php, line 38

Class

AdvanceResize
Defines imagick advance resize operation.

Namespace

Drupal\image_effect\Plugin\ImageToolkit\Operation\imagick

Code

protected function validateArguments(array $arguments) {

  // Assure integers for all arguments.
  $arguments['width'] = (int) round($arguments['width']);
  $arguments['height'] = (int) round($arguments['height']);

  // Fail when width or height are 0 or negative.
  if ($arguments['width'] <= 0) {
    throw new \InvalidArgumentException("Invalid width ('{$arguments['width']}') specified for the image 'resize' operation");
  }
  if ($arguments['height'] <= 0) {
    throw new \InvalidArgumentException("Invalid height ('{$arguments['height']}') specified for the image 'resize' operation");
  }
  return $arguments;
}