You are here

protected function Shadow::process in Imagick 8

File

src/Plugin/ImageToolkit/Operation/imagick/Shadow.php, line 47

Class

Shadow
Defines imagick shadow operation.

Namespace

Drupal\imagick\Plugin\ImageToolkit\Operation\imagick

Code

protected function process(Imagick &$resource, array $arguments) {
  $color = $arguments['color'];
  $opacity = $arguments['opacity'];
  $sigma = $arguments['sigma'];
  $x = $arguments['x'];
  $y = $arguments['y'];
  $color = empty($color) ? 'none' : $color;
  $shadow = clone $resource;
  $shadow
    ->setImageBackgroundColor(new ImagickPixel($color));
  $shadow
    ->shadowImage($opacity, $sigma, $x, $y);
  $success = $shadow
    ->compositeImage($resource, Imagick::COMPOSITE_OVER, -$x + $sigma * 2, -$y + $sigma * 2);
  $resource = $shadow;
  return $success;
}