ReplaceImage.php in Image Effects 8.3
File
src/Plugin/ImageToolkit/Operation/gd/ReplaceImage.php
View source
<?php
namespace Drupal\image_effects\Plugin\ImageToolkit\Operation\gd;
use Drupal\system\Plugin\ImageToolkit\Operation\gd\GDImageToolkitOperationBase;
use Drupal\image_effects\Plugin\ImageToolkit\Operation\ReplaceImageTrait;
class ReplaceImage extends GDImageToolkitOperationBase {
use ReplaceImageTrait;
protected function execute(array $arguments) {
$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;
}
$data = [
'watermark_image' => $arguments['replacement_image'],
'x_offset' => 0,
'y_offset' => 0,
];
return $this
->getToolkit()
->apply('watermark', $data);
}
}