? .imageapi_gd.module.swp
Index: imageapi_gd.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/imageapi/imageapi_gd.module,v
retrieving revision 1.10
diff -u -p -r1.10 imageapi_gd.module
--- imageapi_gd.module	29 May 2008 02:35:31 -0000	1.10
+++ imageapi_gd.module	29 May 2008 02:59:44 -0000
@@ -59,11 +59,18 @@ function imageapi_gd_image_resize(&$imag
 
   $res = _gd_create_tmp($image, $width, $height);
 
-  if (!imagecopyresampled($res, $image->res, 0, 0, 0, 0, $width, $height, $image->info['width'], $image->info['height'])) {
+  $src_width = min($image->info['width'], $width);
+  $src_height = min($image->info['height'], $height);
+  $src_x = max(0, $x);
+  $src_y = max(0, $y);
+  $dst_x = max(0, -$x);
+  $dst_y = max(0, -$y);
+  if (!imagecopyresampled($res, $image->res, $dst_x, $dst_y, $src_x, $src_y, $src_width, $src_height)) {
     return false;
   }
+
+  // destroy the original image and return the modified image.
   imagedestroy($image->res);
-  // update image object
   $image->res = $res;
   $image->info['width'] = $width;
   $image->info['height'] = $height;
