You are here

function image_imagick_trim in Imagick 7

Adds trim to an image

Parameters

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

$fuzz: The fuzz tolerance.

Return value

TRUE or FALSE, based on success.

File

effects/imagick.trim.inc, line 13

Code

function image_imagick_trim(stdClass $image, $fuzz) {
  $res = $image->resource;
  if (!$res
    ->trimImage($fuzz)) {
    return FALSE;
  }

  // Reset image dimensions
  $dimensions = $res
    ->getImageGeometry();
  $res
    ->setImagePage($dimensions['width'], $dimensions['height'], 0, 0);
  $image->info['width'] = $dimensions['width'];
  $image->info['height'] = $dimensions['height'];
  return $res;
}