You are here

protected function ImageOverlay::execute in Image effect kit 8

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/ImageOverlay.php, line 62
Contains \Drupal\iek\Plugin\ImageToolkit\Operation\gd\ImageOverlay.

Class

ImageOverlay
Defines IEK - Overlay operation.

Namespace

Drupal\iek\Plugin\ImageToolkit\Operation\gd

Code

protected function execute(array $arguments = []) {
  $data = $arguments;
  $iek_overlay = iek_get_overlays($data['overlay_name']);
  $overlay_path = \Drupal::service('file_system')
    ->realpath($iek_overlay['path'] . '/' . $iek_overlay['file']);
  $overlay_info = iek_image_get_info($overlay_path);
  $overlay_tmp = iek_gd_create_image($overlay_path);
  imagecopyresampled($this
    ->getToolkit()
    ->getResource(), $overlay_tmp, $data['bg_offset'], $data['bg_offset'], $data['overlay_offset'], $data['overlay_offset'], $this
    ->getToolkit()
    ->getWidth() - $data['bg_offset'] * 2, $this
    ->getToolkit()
    ->getHeight() - $data['bg_offset'] * 2, $overlay_info['width'] - $data['overlay_offset'] * 2, $overlay_info['height'] - $data['overlay_offset'] * 2);
  return TRUE;
}