diff --git a/modules/system/image.gd.inc b/modules/system/image.gd.inc
index a3f76d4..2d4b713 100644
--- a/modules/system/image.gd.inc
+++ b/modules/system/image.gd.inc
@@ -30,6 +30,16 @@ function image_gd_settings() {
     );
     $form['#element_validate'] = array('image_gd_settings_validate');
 
+    $form['imageapi_crop_background'] = array(
+      '#type' => 'textfield',
+      '#title' => t('Crop background color'),
+      '#size' => 10,
+      '#maxlength' => 8,
+      '#default_value' => variable_get('image_crop_background', ''),
+      '#field_prefix' => '#',
+      '#description' => t('Hex string specifying the background color to use when cropping images. If not provided, will use the default. Examples: "RGB", "RGBA", "RRGGBB", "RRGGBBAA".'),
+    );
+
     return $form;
   }
   else {
@@ -185,9 +195,21 @@ function image_gd_rotate(stdClass $image, $degrees, $background = NULL) {
  * @see image_crop()
  */
 function image_gd_crop(stdClass $image, $x, $y, $width, $height) {
+  // Create an image with the new width and height.
   $res = image_gd_create_tmp($image, $width, $height);
 
-  if (!imagecopyresampled($res, $image->resource, 0, 0, $x, $y, $width, $height, $width, $height)) {
+  // Fill the background color if desired.
+  $background = variable_get('image_crop_background', '');
+  if (!empty($background)) {
+    $background = imageapi_hex2rgba($background);
+    $background = imagecolorallocatealpha($res, $background[0], $background[1], $background[2], $background[3]);
+    imagefill($res, 0, 0, $background);
+  }
+
+  // Copy the source image to our new destination image. We use
+  // $image->info['width'] instead of $width because we are copying using the
+  // source image's width and height, not the destination width and height.
+  if (!imagecopyresampled($res, $image->resource, -$x, -$y, 0, 0, $image->info['width'], $image->info['height'], $image->info['width'], $image->info['height'])) {
     return FALSE;
   }
 
