You are here

function image_imagemagick_crop in ImageMagick 7

Crops an image to the given coordinates.

Parameters

$image: An image object. The $image->resource, $image->info['width'], and $image->info['height'] values will be modified by this call.

$x: The starting x offset at which to start the crop, in pixels.

$y: The starting y offset at which to start the crop, in pixels.

$width: The width of the cropped area, in pixels.

$height: The height of the cropped area, in pixels.

Return value

TRUE or FALSE, based on success.

See also

image_crop()

File

./imagemagick.module, line 266
Provides ImageMagick integration.

Code

function image_imagemagick_crop(stdClass $image, $x, $y, $width, $height) {

  // Even though the crop effect in Drupal core does not allow for negative
  // offsets, ImageMagick supports them. Also note: if $x and $y are set to
  // NULL then crop will create tiled images so we convert these to ints.
  $image->ops[] = sprintf('-crop %dx%d%+d%+d!', $width, $height, $x, $y);
  $image->info['width'] = $width;
  $image->info['height'] = $height;
  return TRUE;
}