Index: imagemagick.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/imagemagick/imagemagick.module,v
retrieving revision 1.12
diff -u -p -r1.12 imagemagick.module
--- imagemagick.module	30 Jan 2011 21:03:42 -0000	1.12
+++ imagemagick.module	30 Jan 2011 21:32:49 -0000
@@ -47,7 +47,7 @@ function image_imagemagick_settings() {
   $form['imagemagick']['imagemagick_convert'] = array(
     '#type' => 'textfield',
     '#title' => t('Path to the "convert" binary'),
-    '#default_value' => variable_get('imagemagick_convert', '/usr/bin/convert'),
+    '#default_value' => variable_get('imagemagick_convert', 'convert'),
     '#required' => TRUE,
     '#element_validate' => array('imagemagick_element_validate_path'),
     '#description' => t('The complete path and filename of the ImageMagick <kbd>convert</kbd> binary. For example: <kbd>/usr/bin/convert</kbd> or <kbd>C:\Program Files\ImageMagick-6.3.4-Q16\convert.exe</kbd>'),
@@ -111,21 +111,38 @@ function _imagemagick_build_version($ele
 }
 
 /**
- * Verify ImageMagick installation path.
+ * Verify file path of ImageMagick convert binary.
+ *
+ * @param $file
+ *   The user-submitted file path to the convert binary.
  *
  * @return
- *   A list of errors indicating whether ImageMagick could not be found on this machine.
+ *   A list of errors indicating whether ImageMagick could not be found on this
+ *   machine, which is empty if it was found.
  */
-function _imagemagick_check_path($path) {
+function _imagemagick_check_path($file) {
   $errors = array();
-  if (!is_file($path)) {
-    $errors[] = t('The specified ImageMagick path %file does not exist.', array('%file' => $path));
+
+  // If only the name of the executable is given, check whether it is in the
+  // path and can be invoked.
+  if (dirname($file) === '.') {
+    $status = _imagemagick_convert_exec('-version', $output, $errors, $file);
+    if ($status == 0) {
+      return $errors;
+    }
   }
-  if (!$errors && !is_executable($path)) {
-    $errors[] = t('The specified ImageMagick path %file is not executable.', array('%file' => $path));
+
+  if (!is_file($file)) {
+    $errors[] = t('The specified ImageMagick path %file does not exist.', array('%file' => $file));
   }
-  if ($errors && $open_basedir = ini_get('open_basedir')) {
-    $errors[] = t("PHP's <a href='!open-basedir'>open_basedir</a> security restriction is set to %open-basedir, which may be interfering with attempts to locate ImageMagick.", array('%file' => $path, '%open-basedir' => $open_basedir, '!info-link' => url('http://php.net/features.safe-mode#ini.open-basedir')));
+  if (!$errors && !is_executable($file)) {
+    $errors[] = t('The specified ImageMagick path %file is not executable.', array('%file' => $file));
+  }
+  if ($errors && ($open_basedir = ini_get('open_basedir'))) {
+    $errors[] = t('The PHP <a href="@php-url">open_basedir</a> security restriction is set to %open-basedir, which may prevent to locate ImageMagick.', array(
+      '%open-basedir' => $open_basedir,
+      '@php-url' => 'http://php.net/manual/en/ini.core.php#ini.open-basedir',
+    ));
   }
   return $errors;
 }
@@ -360,11 +377,13 @@ function _imagemagick_convert($source, $
   return file_exists($dest);
 }
 
-function _imagemagick_convert_exec($command_args, &$output, &$errors) {
-  $convert_path = variable_get('imagemagick_convert', '/usr/bin/convert');
-  if ($errors = _imagemagick_check_path($convert_path)) {
-    watchdog('imagemagick', '!errors', array('!errors' => implode('<br />', $errors)), WATCHDOG_ERROR);
-    return FALSE;
+function _imagemagick_convert_exec($command_args, &$output, &$errors, $convert_path = NULL) {
+  if (!isset($convert_path)) {
+    $convert_path = variable_get('imagemagick_convert', '/usr/bin/convert');
+    if ($errors = _imagemagick_check_path($convert_path)) {
+      watchdog('imagemagick', '!errors', array('!errors' => implode('<br />', $errors)), WATCHDOG_ERROR);
+      return FALSE;
+    }
   }
 
   // Specify Drupal's root as the working a working directory so that relative
