You are here

protected function ImageFilter::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/ImageFilter.php, line 66
Contains \Drupal\iek\Plugin\ImageToolkit\Operation\gd\ImageFilter.

Class

ImageFilter
Defines IEK - Filter operation.

Namespace

Drupal\iek\Plugin\ImageToolkit\Operation\gd

Code

protected function execute(array $arguments = []) {
  $data = $arguments;
  $filter_name = $data['filter_name'];
  $repeat = isset($data['repeat']) ? $data['repeat'] : 1;
  $arg1 = $data['arg1'];
  $arg2 = $data['arg2'];
  $arg3 = $data['arg3'];
  $arg4 = $data['arg4'];
  switch ($filter_name) {
    case IMG_FILTER_BRIGHTNESS:
    case IMG_FILTER_CONTRAST:
    case IMG_FILTER_SMOOTH:
      for ($i = 0; $i < $repeat; $i++) {
        imagefilter($this
          ->getToolkit()
          ->getResource(), $filter_name, $arg1);
      }
      break;
    case IMG_FILTER_PIXELATE:
      for ($i = 0; $i < $repeat; $i++) {
        imagefilter($this
          ->getToolkit()
          ->getResource(), $filter_name, $arg1, $arg2);
      }
      break;
    case IMG_FILTER_COLORIZE:
      for ($i = 0; $i < $repeat; $i++) {
        imagefilter($this
          ->getToolkit()
          ->getResource(), $filter_name, $arg1, $arg2, $arg3, $arg4);
      }
      break;
    default:
      for ($i = 0; $i < $repeat; $i++) {
        imagefilter($this
          ->getToolkit()
          ->getResource(), $filter_name);
      }
      break;
  }
  return TRUE;
}