protected function Desaturate::execute in Drupal 10
Same name and namespace in other branches
- 8 core/modules/system/src/Plugin/ImageToolkit/Operation/gd/Desaturate.php \Drupal\system\Plugin\ImageToolkit\Operation\gd\Desaturate::execute()
- 9 core/modules/system/src/Plugin/ImageToolkit/Operation/gd/Desaturate.php \Drupal\system\Plugin\ImageToolkit\Operation\gd\Desaturate::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
- core/
modules/ system/ src/ Plugin/ ImageToolkit/ Operation/ gd/ Desaturate.php, line 29
Class
- Desaturate
- Defines GD2 Desaturate operation.
Namespace
Drupal\system\Plugin\ImageToolkit\Operation\gdCode
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()
->getResource(), IMG_FILTER_GRAYSCALE);
}