You are here

function imageapi_gd_image_desaturate in ImageAPI 6

Same name and namespace in other branches
  1. 5 imageapi_gd.module \imageapi_gd_image_desaturate()

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.

File

./imageapi_gd.module, line 221
GD2 toolkit functions

Code

function imageapi_gd_image_desaturate(&$image) {

  // PHP installations using non-bundled GD do not have imagefilter.
  if (!function_exists('imagefilter')) {
    require_once drupal_get_path('module', 'imageapi_gd') . '/imagefilter.inc';
  }
  return imagefilter($image->resource, IMG_FILTER_GRAYSCALE);
}