function Desaturate::execute

Same name and namespace in other branches
  1. 9 core/modules/system/src/Plugin/ImageToolkit/Operation/gd/Desaturate.php \Drupal\system\Plugin\ImageToolkit\Operation\gd\Desaturate::execute()
  2. 8.9.x core/modules/system/src/Plugin/ImageToolkit/Operation/gd/Desaturate.php \Drupal\system\Plugin\ImageToolkit\Operation\gd\Desaturate::execute()
  3. 10 core/modules/system/src/Plugin/ImageToolkit/Operation/gd/Desaturate.php \Drupal\system\Plugin\ImageToolkit\Operation\gd\Desaturate::execute()

Overrides ImageToolkitOperationBase::execute

File

core/modules/system/src/Plugin/ImageToolkit/Operation/gd/Desaturate.php, line 31

Class

Desaturate
Defines GD2 Desaturate operation.

Namespace

Drupal\system\Plugin\ImageToolkit\Operation\gd

Code

protected function execute(array $arguments) {
    // PHP installations using non-bundled GD do not have imagefilter.
    if (!function_exists('imagefilter')) {
        $this->logger
            ->notice("The image '@file' could not be desaturated because the imagefilter() function is not available in this PHP installation.", [
            '@file' => $this->getToolkit()
                ->getSource(),
        ]);
        return FALSE;
    }
    return imagefilter($this->getToolkit()
        ->getImage(), IMG_FILTER_GRAYSCALE);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.