protected function ReplaceImage::execute in Image Effects 8
Same name in this branch
- 8 src/Plugin/ImageToolkit/Operation/gd/ReplaceImage.php \Drupal\image_effects\Plugin\ImageToolkit\Operation\gd\ReplaceImage::execute()
- 8 src/Plugin/ImageToolkit/Operation/imagemagick/ReplaceImage.php \Drupal\image_effects\Plugin\ImageToolkit\Operation\imagemagick\ReplaceImage::execute()
Same name and namespace in other branches
- 8.3 src/Plugin/ImageToolkit/Operation/gd/ReplaceImage.php \Drupal\image_effects\Plugin\ImageToolkit\Operation\gd\ReplaceImage::execute()
- 8.2 src/Plugin/ImageToolkit/Operation/gd/ReplaceImage.php \Drupal\image_effects\Plugin\ImageToolkit\Operation\gd\ReplaceImage::execute()
Performs the actual manipulation on the image.
Image toolkit operation implementers must implement this method. This method is responsible for actually performing the operation on the image. When this method gets called, the implementer may assume all arguments, also the optional ones, to be available, validated and corrected.
Parameters
array $arguments: An associative array of arguments to be used by the toolkit operation.
Return value
bool TRUE if the operation was performed successfully, FALSE otherwise.
Overrides ImageToolkitOperationBase::execute
File
- src/
Plugin/ ImageToolkit/ Operation/ gd/ ReplaceImage.php, line 26
Class
- ReplaceImage
- Defines GD2 image replace operation.
Namespace
Drupal\image_effects\Plugin\ImageToolkit\Operation\gdCode
protected function execute(array $arguments) {
// Prepare the new image.
$data = [
'width' => $arguments['replacement_image']
->getWidth(),
'height' => $arguments['replacement_image']
->getHeight(),
'extension' => image_type_to_extension($arguments['replacement_image']
->getToolkit()
->getType(), FALSE),
'transparent_color' => $arguments['replacement_image']
->getToolkit()
->getTransparentColor(),
'is_temp' => FALSE,
];
if (!$this
->getToolkit()
->apply('create_new', $data)) {
return FALSE;
}
// Overlay replacement image.
$data = [
'watermark_image' => $arguments['replacement_image'],
'x_offset' => 0,
'y_offset' => 0,
];
return $this
->getToolkit()
->apply('watermark', $data);
}