function image_gd_desaturate

image_gd_desaturate(stdClass $image)

Convert an image resource to grayscale.

Note that transparent GIFs loose transparency when desaturated.

Parameters

$image: An image object. The $image->resource value will be modified by this call.

Return value

TRUE or FALSE, based on success.

See also

image_desaturate()

Related topics

File

modules/system/image.gd.inc, line 233
GD2 toolkit for image manipulation within Drupal.

Code

function image_gd_desaturate(stdClass $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);
}

© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/modules!system!image.gd.inc/function/image_gd_desaturate/7.x