Desaturate.php
Namespace
Drupal\system\Plugin\ImageToolkit\Operation\gdFile
- 
              core/
modules/ system/ src/ Plugin/ ImageToolkit/ Operation/ gd/ Desaturate.php  
View source
<?php
namespace Drupal\system\Plugin\ImageToolkit\Operation\gd;
use Drupal\Core\ImageToolkit\Attribute\ImageToolkitOperation;
use Drupal\Core\StringTranslation\TranslatableMarkup;
/**
 * Defines GD2 Desaturate operation.
 */
class Desaturate extends GDImageToolkitOperationBase {
  
  /**
   * {@inheritdoc}
   */
  protected function arguments() {
    // This operation does not use any parameters.
    return [];
  }
  
  /**
   * {@inheritdoc}
   */
  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);
  }
}
Classes
| Title | Deprecated | Summary | 
|---|---|---|
| Desaturate | Defines GD2 Desaturate operation. | 
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.