You are here

function image_gd_crop in Drupal 4

Same name and namespace in other branches
  1. 5 includes/image.inc \image_gd_crop()
  2. 6 includes/image.gd.inc \image_gd_crop()
  3. 7 modules/system/image.gd.inc \image_gd_crop()

Crop an image using the GD toolkit.

File

includes/image.inc, line 276

Code

function image_gd_crop($source, $destination, $x, $y, $width, $height) {
  $info = image_get_info($source);
  if (!$info) {
    return false;
  }
  $im = image_gd_open($source, $info['extension']);
  $res = imageCreateTrueColor($width, $height);
  imageCopy($res, $im, 0, 0, $x, $y, $width, $height);
  $result = image_gd_close($res, $destination, $info['extension']);
  imageDestroy($res);
  imageDestroy($im);
  return $result;
}