--- ../drupal-5.7-unpatched/includes/image.inc	2007-12-27 03:31:24.000000000 -0500
+++ includes/image.inc	2008-06-11 02:41:50.000000000 -0400
@@ -69,7 +69,6 @@ function image_toolkit_invoke($method, $
   }
 }
 
-
 /**
  * Get details about an image.
  *
@@ -90,7 +89,7 @@ function image_get_info($file) {
   $file_size = @filesize($file);
 
   if (isset($data) && is_array($data)) {
-    $extensions = array('1' => 'gif', '2' => 'jpg', '3' => 'png');
+    $extensions = array('1' => 'gif', '2' => 'jpg', '3' => 'png', '7' => 'tiff');
     $extension = array_key_exists($data[2], $extensions) ?  $extensions[$data[2]] : '';
     $details = array('width'     => $data[0],
                      'height'    => $data[1],
@@ -98,11 +97,22 @@ function image_get_info($file) {
                      'file_size' => $file_size,
                      'mime_type' => $data['mime']);
   }
+  else {
+    $details = image_toolkit_invoke('get_info', $file);
+    $details['file_size'] = $file_size;
+  }
 
   return $details;
 }
 
 /**
+ * Convert an image from one type to another based on file extension.
+ */
+function image_convert($source, $destination) {
+  return image_toolkit_invoke('convert', array($source, $destination));
+}
+
+/**
  * Scales an image to the given width and height while maintaining aspect
  * ratio.
  *
@@ -218,6 +228,51 @@ function image_gd_check_settings() {
 }
 
 /**
+ * Get any info about the image that image_get_info wasn't able to provide.
+ */
+function image_gd_get_info($file) {
+  return FALSE;
+}
+
+/**
+ * Convert an image from one type to another based on file extension.
+ */
+function image_gd_convert($source, $destination) {
+  $source_info = image_get_info($source);
+  switch ($source_info['extension']) {
+    case 'gif':
+      $image = imagecreatefromgif($source);
+      break;
+    case 'jpg':
+      $image = imagecreatefromjpeg($source);
+      break;
+    case 'png':
+      $image = imagecreatefrompng($source);
+      break;
+    default:
+      watchdog('php', t("The GD image toolkit cannot convert from %source.", array('%source' => $source)));
+      return FALSE;
+  }
+
+  $destination_info = path_info($destination, PATHINFO_EXTENSION);
+  switch ($destination_info['extension']) {
+    case 'gif':
+      imagegif($image, $destination);
+      break;
+    case 'jpg':
+    case 'jpeg':
+      imagejpeg($image, $destination);
+      break;
+    case 'png':
+      imagepng($image, $destination);
+      break;
+    default:
+      watchdog('php', t("The GD image toolkit cannot create images of type %extension.", array('%extension' => $destination_info['extension'])));
+      return FALSE;
+  }
+}
+
+/**
  * Scale an image to the specified size using GD.
  */
 function image_gd_resize($source, $destination, $width, $height) {
