image_gd_crop

Versions
4.6 – 6
image_gd_crop($source, $destination, $x, $y, $width, $height)
7
image_gd_crop(stdClass $image, $x, $y, $width, $height)

Crop an image using the GD toolkit.

Code

includes/image.inc, line 257

<?php
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;
}
?>
Login or register to post comments
 
 

All source code and documentation on this site is released under the terms of the GNU General Public License, version 2 and later. Drupal is a registered trademark of Dries Buytaert.