You are here

protected function ReplaceImage::execute in Image Effects 8

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

File

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

Class

ReplaceImage
Defines Imagemagick image replace operation.

Namespace

Drupal\image_effects\Plugin\ImageToolkit\Operation\imagemagick

Code

protected function execute(array $arguments) {
  $replacement = $arguments['replacement_image'];

  // Replacement image local path.
  $local_path = $replacement
    ->getToolkit()
    ->getSourceLocalPath();
  if ($local_path === '') {
    $source_path = $replacement
      ->getToolkit()
      ->getSource();
    throw new \InvalidArgumentException("Missing local path for image at {$source_path}");
  }
  $this
    ->getToolkit()
    ->resetArguments()
    ->setSourceLocalPath($replacement
    ->getToolkit()
    ->getSourceLocalPath())
    ->setSourceFormat($replacement
    ->getToolkit()
    ->getSourceFormat())
    ->setExifOrientation($replacement
    ->getToolkit()
    ->getExifOrientation())
    ->setWidth($replacement
    ->getWidth())
    ->setHeight($replacement
    ->getHeight());
  return TRUE;
}