You are here

protected function Composite::process in Imagick 8

File

src/Plugin/ImageToolkit/Operation/imagick/Composite.php, line 48

Class

Composite
Defines imagick blur operation.

Namespace

Drupal\imagick\Plugin\ImageToolkit\Operation\imagick

Code

protected function process(Imagick $resource, array $arguments) {

  // Get the correct path
  $path = $arguments['path'];
  if (!UrlHelper::isExternal($path)) {
    $path = \Drupal::service('file_system')
      ->realpath($path);
  }
  if (!file_exists($path)) {
    return FALSE;
  }

  // Get the composite image
  $composite = new Imagick($path);

  // Create channel using bitwise operator
  $channel = array_reduce($arguments['channel'], function ($a, $b) {
    return $a | $b;
  }, 0);
  return $resource
    ->compositeImage($composite, $arguments['composite'], $arguments['x'], $arguments['y'], $channel);
}