You are here

function image_desaturate_effect in Drupal 7

Image effect callback; Desaturate (grayscale) an image resource.

Parameters

$image: An image object returned by image_load().

$data: An array of attributes to use when performing the desaturate effect.

Return value

TRUE on success. FALSE on failure to desaturate image.

See also

image_desaturate()

1 call to image_desaturate_effect()
ImageEffectsUnitTest::testDesaturateEffect in modules/image/image.test
Test the image_desaturate_effect() function.
2 string references to 'image_desaturate_effect'
hook_image_styles_alter in modules/image/image.api.php
Modify any image styles provided by other modules or the user.
image_image_effect_info in modules/image/image.effects.inc
Implements hook_image_effect_info().

File

modules/image/image.effects.inc, line 226
Functions needed to execute image effects provided by Image module.

Code

function image_desaturate_effect(&$image, $data) {
  if (!image_desaturate($image)) {
    watchdog('image', 'Image desaturate failed using the %toolkit toolkit on %path (%mimetype, %dimensions)', array(
      '%toolkit' => $image->toolkit,
      '%path' => $image->source,
      '%mimetype' => $image->info['mime_type'],
      '%dimensions' => $image->info['width'] . 'x' . $image->info['height'],
    ), WATCHDOG_ERROR);
    return FALSE;
  }
  return TRUE;
}