diff -upN empty/gd.info modules/gd/gd.info
--- empty/gd.info	1969-12-31 16:00:00.000000000 -0800
+++ modules/gd/gd.info	2008-02-20 16:42:35.000000000 -0800
@@ -0,0 +1,6 @@
+; $Id: $
+name = GD2
+description = Uses PHP's built-in GD2 image processing support.
+package = Core - optional
+version = VERSION
+core = 7.x
diff -upN empty/gd.install modules/gd/gd.install
--- empty/gd.install	1969-12-31 16:00:00.000000000 -0800
+++ modules/gd/gd.install	2008-02-20 16:42:35.000000000 -0800
@@ -0,0 +1,35 @@
+<?php
+// $Id: $
+
+function gd_requirements($phase) {
+  $requirements = array();
+
+  if ($phase == 'runtime') {
+    // Check GD library
+    if (function_exists('imagegd2')) {
+      $info = gd_info();
+      $requirements['gd'] = array(
+        'value' => $info['GD Version'],
+      );
+
+      // Check PNG support
+      if (function_exists('imagecreatefrompng')) {
+        $requirements['gd']['severity'] = REQUIREMENT_OK;
+      }
+      else {
+        $requirements['gd']['severity'] = REQUIREMENT_ERROR;
+        $requirements['gd']['description'] = t('The GD library for PHP is enabled, but was compiled without PNG support. Please check the <a href="@url">PHP image documentation</a> for information on how to correct this.', array('@url' => 'http://www.php.net/manual/en/ref.image.php'));
+      }
+    }
+    else {
+      $requirements['gd'] = array(
+        'value' => t('Not installed'),
+        'severity' => REQUIREMENT_ERROR,
+        'description' => t('The GD library for PHP is missing or outdated. Please check the <a href="@url">PHP image documentation</a> for information on how to correct this.', array('@url' => 'http://www.php.net/manual/en/ref.image.php')),
+      );
+    }
+    $requirements['gd']['title'] = t('GD library');
+  }
+
+  return $requirements;
+}
diff -upN empty/gd.module modules/gd/gd.module
--- empty/gd.module	1969-12-31 16:00:00.000000000 -0800
+++ modules/gd/gd.module	2008-02-20 16:42:35.000000000 -0800
@@ -0,0 +1,100 @@
+<?php
+// $id: $
+
+/**
+ * @file
+ * GD2 toolkit functions
+ */
+
+/**
+ * Settings form for the toolkit.
+ */
+function gd_settings_form() {
+  $form['image_jpeg_quality'] = array(
+    '#type' => 'textfield',
+    '#title' => t('JPEG quality'),
+    '#description' => t('Define the image quality for JPEG manipulations. Ranges from 0 to 100. Higher values mean better image quality, but bigger files.'),
+    '#size' => 10,
+    '#maxlength' => 3,
+    '#default_value' => variable_get('image_jpeg_quality', 75),
+    '#field_suffix' => '%',
+  );
+  return system_settings_form($form);
+}
+
+/**
+ * Implementation of hook_image_toolkit().
+ */
+function gd_image_toolkit($op, $source = NULL, $destination = NULL, $params = array()) {
+  if (!file_exists($source)) {
+    return FALSE;
+  }
+  
+  $info = image_get_info($source);
+  if (!$info) {
+    return FALSE;
+ }
+  
+  $im = _gd_open($source, $info['extension']);
+  if (!$im) {
+    return FALSE;
+  }
+  
+  switch ($op) {
+    case 'crop':
+      $res = imageCreateTrueColor($params['width'], $params['height']);
+      imageCopy($res, $im, 0, 0, $params['x'], $params['y'], $params['width'], $params['height']);
+      break;
+      
+    case 'resize':
+      $res = imageCreateTrueColor($params['width'], $params['height']);
+      if ($info['extension'] == 'png') {
+        $transparency = imagecolorallocatealpha($res, 0, 0, 0, 127);
+        imagealphablending($res, FALSE);
+        imagefilledrectangle($res, 0, 0, $params['width'], $params['height'], $transparency);
+        imagealphablending($res, TRUE);
+        imagesavealpha($res, TRUE);
+      }
+      imageCopyResampled($res, $im, 0, 0, 0, 0, $params['width'], $params['height'], $info['width'], $info['height']);
+      break;
+      
+    case 'rotate':
+      $res = imageRotate($im, $params['degrees'], $params['bg_color']);
+      break;
+  }
+  $result = _gd_close($res, $destination, $info['extension']);
+
+  imageDestroy($im);
+  imageDestroy($res);
+
+  return $result;
+}
+
+/**
+ * GD helper function to create an image resource from a file.
+ */
+function _gd_open($file, $extension) {
+  $extension = str_replace('jpg', 'jpeg', $extension);
+  $open_func = 'imageCreateFrom'. $extension;
+  if (!function_exists($open_func)) {
+    return FALSE;
+  }
+  return $open_func($file);
+}
+
+/**
+ * GD helper to write an image resource to a destination file.
+ */
+function _gd_close($res, $destination, $extension) {
+  $extension = str_replace('jpg', 'jpeg', $extension);
+  $close_func = 'image'. $extension;
+  if (!function_exists($close_func)) {
+    return FALSE;
+  }
+  if ($extension == 'jpeg') {
+    return $close_func($res, $destination, variable_get('image_jpeg_quality', 75));
+  }
+  else {
+    return $close_func($res, $destination);
+  }
+}
