public function GDToolkit::desaturate

Implements \Drupal\system\Plugin\ImageToolkitInterface::desaturate().

Overrides ImageToolkitInterface::desaturate

File

drupal/core/modules/system/lib/Drupal/system/Plugin/ImageToolkit/GDToolkit.php, line 143
Contains \Drupal\system\Plugin\ImageToolkit\GDToolkit;.

Class

GDToolkit
Defines the GD2 toolkit for image manipulation within Drupal.

Namespace

Drupal\system\Plugin\ImageToolkit

Code

public function desaturate($image) {

  // PHP installations using non-bundled GD do not have imagefilter.
  if (!function_exists('imagefilter')) {
    watchdog('image', 'The image %file could not be desaturated because the imagefilter() function is not available in this PHP installation.', array(
      '%file' => $image->source,
    ));
    return FALSE;
  }
  return imagefilter($image->resource, IMG_FILTER_GRAYSCALE);
}