Index: includes/image.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/image.inc,v
retrieving revision 1.17.2.1
diff -u -p -r1.17.2.1 image.inc
--- includes/image.inc	27 Dec 2007 08:31:24 -0000	1.17.2.1
+++ includes/image.inc	7 Apr 2008 07:52:30 -0000
@@ -298,14 +298,23 @@ function image_gd_rotate($source, $desti
  * Crop an image using the GD toolkit.
  */
 function image_gd_crop($source, $destination, $x, $y, $width, $height) {
+  static $bg_rgb;
+  if(!count($bg_rgb)) {
+    $bg_color = variable_get('image_crop_background', '#FF0000');
+    preg_match_all('/\#?(\w\w)(\w\w)(\w\w)/',$bg_color,$matches);
+    unset($matches[0]);
+    $i=0;
+    foreach($matches as &$c) { $bg_rgb[$i++]=hexdec($c[0]);}
+  }
   $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);
+  $bg_color_tr=imagecolorallocatealpha($res,$bg_rgb[0],$bg_rgb[1],$bg_rgb[2],127);
+  imagefill($res, 0, 0, $bg_color_tr);
+  imagecopy($res, $im, -$x, -$y, 0, 0, $info['width'], $info['height']);
   $result = image_gd_close($res, $destination, $info['extension']);
 
   imageDestroy($res);
