Index: includes/image.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/image.inc,v
retrieving revision 1.4
diff -u -r1.4 image.inc
--- includes/image.inc	29 Mar 2005 00:01:23 -0000	1.4
+++ includes/image.inc	29 Mar 2005 10:17:16 -0000
@@ -13,12 +13,22 @@
   foreach ($toolkits as $file => $toolkit) {
     include_once($file);
     $function = str_replace('.', '_', $toolkit->name) .'_info';
-    if (function_exists($function)) {
+    if (function_exists($function)) { // check if there's an info() function
       $info = $function();
-      $output[$info['name']] = $info['title'];
+
+      $function = str_replace('.', '_', $toolkit->name) .'_check';
+      if (function_exists($function)) { // make sure toolkit works
+        if ($function()) {
+          $output[$info['name']] = $info['title']; // advertise the toolkit
+        }
+      }
     }
   }
-  $output['gd'] = t('Built-in GD2 toolkit');
+
+  if (count($toolkits) == 0) {
+    watchdog('php', t("No image handling toolkits are available.  Either none are installed or your server does not have the proper image manipulation support."), WATCHDOG_ERROR);
+  }
+
   return $output;
 }
 
@@ -30,12 +40,12 @@
 function image_get_toolkit() {
   static $toolkit;
   if (!$toolkit) {
-    $toolkit = variable_get('image_toolkit', 'gd');
+    $toolkit = variable_get('image_toolkit', NULL);
     $toolkit_file = 'includes/image.'.$toolkit.'.inc';
-    if ($toolkit != 'gd' && file_exists($toolkit_file)) {
+    if (file_exists($toolkit_file)) {
       include_once $toolkit_file;
     }
-    elseif (!image_gd_check_settings()) {
+    else {
       $toolkit = false;
     }
   }
@@ -63,13 +73,11 @@
     }
   }
   else {
-    if ($method == 'settings') {
-      return image_gd_settings();
-    }
+    watchdog('php', t("No image handling toolkits are available.  Either none are installed or your server does not have the proper image manipulation support."), WATCHDOG_ERROR);
+      return false;
   }
 }
 
-
 /**
  * Get details about an image.
  *
@@ -167,133 +175,4 @@
   return image_toolkit_invoke('crop', array($source, $destination, $x, $y, $width, $height));
 }
 
-/**
- * GD2 toolkit functions
- * With the minimal requirements of PHP 4.3 for Drupal, we use the built-in version of GD.
- */
-
-/**
- * Retrieve settings for the GD2 toolkit (not used).
- */
-function image_gd_settings() {
-  if (image_gd_check_settings()) {
-    return t('The built-in GD2 toolkit is installed and working properly.');
-  }
-  else {
-    form_set_error('image_toolkit', t("The built-in GD image toolkit requires that the GD module for PHP be installed and configured properly. For more information see %url.", array('%url' => '<a href="http://php.net/image">http://php.net/image</a>')));
-    return false;
-  }
-}
-
-/**
- * Verify GD2 settings (that the right version is actually installed).
- *
- * @return boolean
- */
-function image_gd_check_settings() {
-  if ($check = get_extension_funcs('gd')) {
-    if (in_array('imagegd2', $check)) {
-      // GD2 support is available.
-      return true;
-    }
-  }
-  return false;
-}
-
-/**
- * Scale an image to the specified size using GD.
- */
-function image_gd_resize($source, $destination, $width, $height) {
-  if (!file_exists($source)) {
-    return false;
-  }
-
-  $info = image_get_info($source);
-  if (!$info) {
-    return false;
-  }
-
-  $im = image_gd_open($source, $info['extension']);
-  if (!$im) {
-    return false;
-  }
-
-  $res = imageCreateTrueColor($width, $height);
-  imageCopyResampled($res, $im, 0, 0, 0, 0, $width, $height, $info['width'], $info['height']);
-  $result = image_gd_close($res, $destination, $info['extension']);
-
-  imageDestroy($res);
-  imageDestroy($im);
-
-  return $result;
-}
-
-/**
- * Rotate an image the given number of degrees.
- */
-function image_gd_rotate($source, $destination, $degrees, $bg_color = 0) {
-  if (!function_exists('imageRotate')) {
-    return false;
-  }
-
-  $info = image_get_info($source);
-  if (!$info) {
-    return false;
-  }
-
-  $im = image_gd_open($source, $info['extension']);
-  if (!$im) {
-    return false;
-  }
-
-  $res = imageRotate($im, $degrees, $bg_color);
-  $result = image_gd_close($res, $destination, $info['extension']);
-
-  return $result;
-}
-
-/**
- * Crop an image using the GD toolkit.
- */
-function image_gd_crop($source, $destination, $x, $y, $width, $height) {
-  $info = image_get_info($source);
-  if (!$info) {
-    return false;
-  }
-
-  $im = image_gd_open($source, $info['extension']);
-  $res = imageCreateTrueColor($width, $height);
-  imageCopy($im, $res, 0, 0, $x, $y, $width, $height);
-  $result = image_gd_close($res, $destination, $info['extension']);
-
-  imageDestroy($res);
-  imageDestroy($im);
-
-  return $result;
-}
-
-/**
- * GD helper function to create an image resource from a file.
- */
-function image_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 image_gd_close($res, $destination, $extension) {
-  $extension = str_replace('jpg', 'jpeg', $extension);
-  $close_func = 'image'. $extension;
-  if (!function_exists($close_func)) {
-    return false;
-  }
-  return $close_func($res, $destination);
-}
-
-?>
+?>
\ No newline at end of file
Index: modules/system.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/system.module,v
retrieving revision 1.203
diff -u -r1.203 system.module
--- modules/system.module	27 Mar 2005 23:37:20 -0000	1.203
+++ modules/system.module	29 Mar 2005 10:19:17 -0000
@@ -245,9 +245,15 @@
   $group = '';
   $toolkits_available = image_get_available_toolkits();
   if (count($toolkits_available) > 1) {
-      $group .= form_radios(t('Select an image processing toolkit'), 'image_toolkit', variable_get('image_toolkit', image_get_toolkit()), $toolkits_available);
+    $group .= form_radios(t('Select an image processing toolkit'), 'image_toolkit', variable_get('image_toolkit', image_get_toolkit()), $toolkits_available);
+  }
+  else if (count($toolkits_available) == 1) {
+    variable_set('image_toolkit', key($toolkits_available));
+  }
+
+  if (count($toolkits_available) > 0) {
+    $group .= image_toolkit_invoke('settings') ? image_toolkit_invoke('settings') : t("The %toolkit toolkit contains no settings.", array('%toolkit' => image_get_toolkit()));
   }
-  $group .= image_toolkit_invoke('settings');
   if ($group) {
     $output .= form_group(t('Image handling'), $group);
   }
