Index: imageapi.info
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/imageapi/imageapi.info,v
retrieving revision 1.2
diff -u -p -r1.2 imageapi.info
--- imageapi.info	21 Feb 2008 11:21:05 -0000	1.2
+++ imageapi.info	14 Apr 2008 05:04:56 -0000
@@ -2,3 +2,5 @@
 name = ImageAPI
 description = ImageAPI supporting multiple toolkits.
 package = ImageCache
+core = 6.x
+php = 5.2
Index: imageapi.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/imageapi/imageapi.module,v
retrieving revision 1.9
diff -u -p -r1.9 imageapi.module
--- imageapi.module	30 Mar 2008 23:25:10 -0000	1.9
+++ imageapi.module	14 Apr 2008 05:04:57 -0000
@@ -4,55 +4,53 @@
 /**
  * @file
  *
- * An ImageAPI supporting additional image plugins as modules. 
+ * An ImageAPI supporting additional image plugins as modules.
  * Images are treated as objects, and images are not written per
  * manipulation as Drupal's core image handling works.
- * 
- * 
- * imageapi image api workflow... 
+ *
+ *
+ * imageapi image api workflow...
  * $image = imageapi_image_open($path) to get an image object for $path...
  * image_X($image, $arg1, $arg2)  to manipulate image object...
  * imageapi_image_close($image) to overwrite original image.
- * 
+ *
  */
 
-define('IMAGEAPI_MINIMUM_PHP', '5.2');
-function imageapi_menu($may_cache) {
+function imageapi_menu() {
   $items = array();
-  if ($may_cache) {
-    $items[] = array(
-      'path' => 'admin/settings/imageapi',
-      'title' => t('ImageAPI'),
-      'description' => t('Configure ImageAPI.'),
-      'callback' => 'drupal_get_form',
-      'callback arguments' => array('imageapi_settings'),
+  $items['admin/settings/imageapi'] = array(
+    'title' => 'ImageAPI',
+    'description' => 'Configure ImageAPI.',
+    'page callback' => 'drupal_get_form',
+    'page arguments' => array('imageapi_settings'),
+    'access arguments' => array('administer imageapi'),
+  );
+
+  $toolkits = imageapi_get_available_toolkits();
+  if ($toolkits) {
+    $items['admin/settings/imageapi/list'] = array(
+      'title' => 'List',
+      'type' => MENU_DEFAULT_LOCAL_TASK,
+      'weight' => -1,
     );
-  }
-  else {
-    $toolkits = imageapi_get_available_toolkits();
-    if ($toolkits) {
-      $items[] = array(
-        'path' => 'admin/settings/imageapi/list',
-        'title' => 'List',
-        'type' => MENU_DEFAULT_LOCAL_TASK,
-        'weight' => -1,
-      );
-      $items[] = array(
-        'path' => 'admin/settings/imageapi/config',
-        'title' => 'Configure',
-        'type' => MENU_LOCAL_TASK,
-        'callback' => 'drupal_get_form',
-        'callback arguments' => array(imageapi_default_toolkit() .'_settings_form'),
-      );
-      foreach ($toolkits as $module => $info) {
-        $items[] = array(
-          'path' => 'admin/settings/imageapi/config/'. $module,
+    $items['admin/settings/imageapi/config'] = array(
+      'title' => 'Configure',
+      'type' => MENU_LOCAL_TASK,
+      'page callback' => 'drupal_get_form',
+      'page arguments' => array(imageapi_default_toolkit() .'_settings_form'),
+      'access arguments' => array('administer imageapi'),
+    );
+    foreach ($toolkits as $module => $info) {
+      if (function_exists($module .'_settings_form')) {
+        $items['admin/settings/imageapi/config/'. $module] = array(
           'title' => $info['name'],
-          'callback' => 'drupal_get_form',
-          'callback arguments' => array($module .'_settings_form'),
+          'page callback' => 'drupal_get_form',
+          'page arguments' => array($module .'_settings_form'),
+          'access arguments' => array('administer imageapi'), 
           'type' => $module == imageapi_default_toolkit() ? MENU_DEFAULT_LOCAL_TASK : MENU_LOCAL_TASK,
         );
       }
+      else {dsm("mssing"); }
     }
   }
   return $items;
@@ -67,16 +65,16 @@ function imageapi_settings() {
     case 0:
       $form['imageapi_toolkits']['#value'] = t('There are no image toolkit modules enabled. Toolkit modules can be enabled from the <a href="!admin-build-modules">module configuration page</a>.', array('!admin-build-modules' => url('admin/build/modules')));
       return $form;
-    
+
     case 1:
       $toolkit = key($toolkits);
-      // The variable needs to be manually set. Otherwise, if a user has two 
-      // toolkits and disables the selected one they won't be able to select the 
+      // The variable needs to be manually set. Otherwise, if a user has two
+      // toolkits and disables the selected one they won't be able to select the
       // remaing toolkit.
-      variable_set('imageapi_toolkit', $toolkit);
+      variable_set('imageapi_image_toolkit', $toolkit);
       $form['imageapi_image_toolkit']['#value'] = t('The %toolkit module is the only enabled image toolkit. Drupal will use it for resizing, cropping and other image manipulations.', array('%toolkit' => $toolkits[$toolkit]['name']));
       return $form;
-            
+
     default:
       $options = array();
       foreach ($toolkits as $module => $info) {
@@ -95,49 +93,30 @@ function imageapi_settings() {
 }
 
 /**
- *  Implementation of hook_requirements().
- */
-function imageapi_requirements($phase) {
-  $requirements = array();
-  // Ensure translations don't break at install time
-  $t = get_t();
-
-  if (version_compare(phpversion(), IMAGEAPI_MINIMUM_PHP) < 0) {
-    $requirements['imageapi_php'] = array(
-      'title' => $t('ImageAPI PHP'),
-      'description' => $t('ImageAPI requires at least PHP %version.', array('%version' => IMAGEAPI_MINIMUM_PHP)),
-      'severity' => REQUIREMENT_ERROR
-    );
-  }
-  
-  return $requirements;
-}
-
-/**
  * Return a list of available toolkits.
  *
- * @return 
+ * @return
  *   An array of the enabled image toolkit modules. The module name is the key
- *   and the value is a sub-array with the module's 'name' and 'description'.  
+ *   and the value is a sub-array with the module's 'name' and 'description'.
  */
 function imageapi_get_available_toolkits() {
   static $toolkits;
- 
+
   if (!isset($toolkits)) {
     $toolkits = array();
     foreach (module_implements('imageapi_toolkit', TRUE) as $module) {
-      $info = _module_parse_info_file(drupal_get_path('module', $module) .'/'. $module .'.info');
+      $info = drupal_parse_info_file(drupal_get_path('module', $module) .'/'. $module .'.info');
       $toolkits[$module] = array('name' => $info['name'], 'description' => $info['description']);
     }
   }
-  
+
   return $toolkits;
 }
 
 /**
  * Retrieve the name of the currently used toolkit.
  *
- * @return 
+ * @return
  *   String containing the name of the toolkit, or FALSE if none is available.
  */
 function imageapi_default_toolkit() {
@@ -170,7 +149,7 @@ function imageapi_image_scale_and_crop(&
   $scale = max($width / $image->info['width'], $height / $image->info['height']);
   $x = round(($image->info['width'] * $scale - $width) / 2);
   $y = round(($image->info['height'] * $scale - $height) / 2);
- 
+
   if (imageapi_image_resize($image, $image->info['width'] * $scale, $image->info['height'] * $scale)) {
     return imageapi_image_crop($image, $x, $y, $width, $height);
   }
@@ -207,10 +186,10 @@ function imageapi_image_scale(&$image, $
   else {
     $width = (int) round($height / $aspect);
   }
-  
+
   return call_user_func($image->toolkit .'_image_resize', $image, $width, $height);
 }
- 
+
 /**
  * Resize an image to the given dimensions (ignoring aspect ratio).
  *
@@ -231,7 +210,7 @@ function imageapi_image_scale(&$image, $
 function imageapi_image_resize(&$image, $width, $height) {
   return call_user_func($image->toolkit .'_image_resize', $image, $width, $height);
 }
- 
+
 /**
  * Rotate an image by the given number of degrees.
  *
@@ -242,8 +221,8 @@ function imageapi_image_resize(&$image, 
  * @param $degrees
  *   The number of (clockwise) degrees to rotate the image.
  * @param $bg_color
- *   An hexidecimal integer specifying the background color to use for the 
- *   uncovered area of the image after the rotation. E.g. 0x000000 for black, 
+ *   An hexidecimal integer specifying the background color to use for the
+ *   uncovered area of the image after the rotation. E.g. 0x000000 for black,
  *   0xff00ff for magenta, and 0xffffff for white.
  * @param $toolkit
  *   An optional override of the default image toolkit.
@@ -253,7 +232,7 @@ function imageapi_image_resize(&$image, 
 function imageapi_image_rotate(&$image, $degrees, $bgcolor = 0x000000) {
   return call_user_func($image->toolkit .'_image_rotate', $image, $degrees, $bgcolor);
 }
- 
+
 /**
  * Crop an image to the rectangle specified by the given rectangle.
  *
@@ -267,13 +246,13 @@ function imageapi_image_rotate(&$image, 
  *   The target width in pixels.
  * @param $height
  *   The target height in pixels.
- * @return 
+ * @return
  *   modifed image object.
  */
 function imageapi_image_crop(&$image, $x, $y, $width, $height) {
   return call_user_func($image->toolkit .'_image_crop', $image, $x, $y, $width, $height);
 }
- 
+
 
 function imageapi_image_desaturate(&$image) {
   return call_user_func($image->toolkit .'_image_desaturate', $image);
@@ -292,7 +271,7 @@ function imageapi_image_open($file, $too
       return $image;
     }
   }
-  watchdog('imageapi', t('ImageAPI failed to open %file with %toolkit', array('%file' => $file, '%toolkit' => $toolkit)), WATCHDOG_WARNING);
+  watchdog('imageapi', 'ImageAPI failed to open %file with %toolkit', array('%file' => $file, '%toolkit' => $toolkit), WATCHDOG_WARNING);
   return FALSE;
 }
 
@@ -314,7 +293,8 @@ function imageapi_image_close($image, $d
     if (@chmod($destination, 0775)) {
       return $return;
     } 
-    watchdog('imageapi', t('Could not set permissons on destination file: %file', array('%file' => $destination)));
+    watchdog('imageapi', 'Could not set permissons on destination file: %file', array('%file' => $destination));
   }
   return FALSE;
 }
+
Index: imageapi_gd.info
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/imageapi/imageapi_gd.info,v
retrieving revision 1.2
diff -u -p -r1.2 imageapi_gd.info
--- imageapi_gd.info	21 Feb 2008 11:21:05 -0000	1.2
+++ imageapi_gd.info	14 Apr 2008 05:04:57 -0000
@@ -2,4 +2,5 @@
 name = ImageAPI GD2
 description = Uses PHP's built-in GD2 image processing support.
 package = ImageCache
-dependencies = imageapi
+dependencies[] = imageapi
+core = 6.x
Index: imageapi_gd.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/imageapi/imageapi_gd.module,v
retrieving revision 1.3
diff -u -p -r1.3 imageapi_gd.module
--- imageapi_gd.module	30 Mar 2008 23:13:11 -0000	1.3
+++ imageapi_gd.module	14 Apr 2008 05:04:57 -0000
@@ -53,7 +53,7 @@ function imageapi_gd_image_crop(&$image,
   $image->info['width'] = $width;
   $image->info['height'] = $height;
   return TRUE;
-  
+
 }
 
 function imageapi_gd_image_resize(&$image, $width, $height) {
@@ -100,14 +100,14 @@ function imageapi_gd_image_rotate(&$imag
   imageDestroy($image->res);
   $image->res = $res;
   return TRUE;
-} 
+}
 
 function imageapi_gd_image_desaturate(&$image) {
   if (function_exists('imagefilter')) { // PHP 5
     if (!imagefilter($image->res, IMG_FILTER_GRAYSCALE)) {
        return FALSE;
     }
-  } 
+  }
   else {                              // PHP < 5
     $res = imageCreateTrueColor($image->info['width'], $image->info['height']);
     for ($y = 0; $y < $image->info['height']; ++$y) {
@@ -117,22 +117,22 @@ function imageapi_gd_image_desaturate(&$
           $red   = ($rgb >> 16) & 0xFF;
           $green = ($rgb >> 8)  & 0xFF;
           $blue  = $rgb & 0xFF;
-        } 
+        }
         else {
           $rgb = imagecolorsforindex($image->res, $rgb);
           $red   = $rgb['red'];
           $green = $rgb['green'];
           $blue  = $rgb['blue'];
         }
-         
+
         $gray = round(.299*$red + .587*$green + .114*$blue);
-         
+
         // shift gray level to the left
         $grayR = $gray << 16;   // R: red
         $grayG = $gray << 8;    // G: green
         $grayB = $gray;         // B: blue
         $grayColor = $grayR | $grayG | $grayB;
-        
+
         // set the pixel color
         imagesetpixel($res, $x, $y, $grayColor);
         imagecolorallocate($res, $gray, $gray, $gray);
Index: imageapi_imagemagick.info
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/imageapi/imageapi_imagemagick.info,v
retrieving revision 1.1
diff -u -p -r1.1 imageapi_imagemagick.info
--- imageapi_imagemagick.info	2 Apr 2008 06:48:17 -0000	1.1
+++ imageapi_imagemagick.info	14 Apr 2008 05:04:57 -0000
@@ -2,4 +2,6 @@
 name = ImageAPI ImageMagick
 description = Command Line ImageMagick support.
 package = ImageCache
-dependencies = imageapi
+dependencies[] = imageapi
+core = 6.x
+
Index: imageapi_imagemagick.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/imageapi/imageapi_imagemagick.module,v
retrieving revision 1.3
diff -u -p -r1.3 imageapi_imagemagick.module
--- imageapi_imagemagick.module	2 Apr 2008 07:57:29 -0000	1.3
+++ imageapi_imagemagick.module	14 Apr 2008 05:04:57 -0000
@@ -27,9 +27,8 @@ function imageapi_imagemagick_settings_f
     '#maxlength' => 3,
     '#default_value' => variable_get('imageapi_imagemagick_quality', 75),
     '#field_suffix' => '%',
-    '#validate' => array('imageapi_imagemagick_quality_element_validate' => array()),
+    '#element_validate' => array('imageapi_imagemagick_quality_element_validate'),
   );
-  $form['#after_build'] = array('_imageapi_imagemagick_build_version');
   
   $form['imageapi_imagemagick_binary'] = array(
     '#type' => 'fieldset',
@@ -43,37 +42,32 @@ function imageapi_imagemagick_settings_f
     '#default_value' => variable_get('imageapi_imagemagick_convert', '/usr/bin/convert'),
     '#required' => TRUE,
     '#description' => t('Specify the complete path to the ImageMagic <kbd>convert</kbd> binary. For example: <kbd>/usr/bin/convert</kbd> or <kbd>C:\Program Files\ImageMagick-6.3.4-Q16\convert.exe</kbd>'),
-    '#validate' => array('_imageapi_imagemagick_checkpath' => array()),
   );
   $form['imageapi_imagemagick_binary']['imageapi_imagemagick_debugging'] = array(
     '#type' => 'checkbox',
     '#title' => t('Display debugging information'),
     '#default_value' => variable_get('imageapi_imagemagick_debugging', 0),
     '#description' => t('Checking this option will display the ImageMagick commands and ouput to users with the <em>administer site configuration</em> permission.'),
+    '#weight' => 2,
   );
-  return system_settings_form($form);
-}
+  $form['#after_build'][] = '_imageapi_imagemagick_build_version';
 
-function _imageapi_imagemagick_build_version($form, $form_element) {
-  _imageapi_imagemagick_convert_exec('-version', $output, $errors);
-  $form['imageapi_imagemagick_binary']['version'] = array(
-    '#type' => 'item',
-    '#value' => '<pre>'. check_plain(trim($output)) .'</pre>',
-  );
-  return $form;
+  return system_settings_form($form);
 }
 
-function _imageapi_imagemagick_validate_path($element) {
-  if (_imageapi_imagemagick_check_path($element['#value'])) {
-    return TRUE;
-  }
-  if ($open_basedir = ini_get('open_basedir')) {
-    form_set_error($element['#parents'][0], t("No file %file could be found. PHP's <a href='!open-basedir'>open_basedir</a> security resriction is set to %open-basedir, which may be interfearing with the attempts to locate ImageMagick.", array('%file' => $path, '%open-basedir' => $open_basedir, '!info-link' => url('http://php.net/features.safe-mode#ini.open-basedir') )));
-  }
-  else {
-    form_set_error($element['#parents'][0], t('The specified ImageMagick path %file does not exist.', array('%file' => $path)));
+function _imageapi_imagemagick_build_version($form, &$form_state) {
+  $path = $form_state['values']['imageapi_imagemagick_convert'];
+  if (_imageapi_imagemagick_check_path($path, 'imageapi_imagemagick_convert')) {
+    _imageapi_imagemagick_convert_exec('-version', $output, $errors, $path);
+    $form['imageapi_imagemagick_binary']['version'] = array(
+      '#type' => 'item',
+      '#title' => t('Version information'),
+      '#value' => '<pre>'. check_plain(trim($output)) .'</pre>',
+      '#description' => t('The ImageMagick <kbd>convert</kbd> binary was located and return this version information.'),
+      '#weight' => 1,
+    );
   }
-  return FALSE;
+  return $form;
 }
 
 function imageapi_imagemagick_quality_element_validate($element) {  
@@ -88,70 +82,40 @@ function imageapi_imagemagick_image_open
   if (!file_copy($image->source, $image->res)) {
     return FALSE;
   }
+  $image->ops = array();
   register_shutdown_function('file_delete', $image->res);
   return $image;
 }
 
 function imageapi_imagemagick_image_close($image, $dst) {
+  if (!_imageapi_imagemagick_convert($image->res, $image->res, $image->ops)) {
+    return FALSE;
+  }
   return file_move($image->res, $dst);
 }
 
 function imageapi_imagemagick_image_crop(&$image, $x, $y, $width, $height) {
-  $args = array('crop' => '-crop '. (int) $width .'x'. (int) $height .'+'. (int) $x .'+'. (int) $y .'!');
-  $args = _imageapi_imagemagick_alter_invoke('crop', $source, $args);
-  if (!_imageapi_imagemagick_convert($source, $dest, $args)) {
-    return FALSE;
-  }
+  $image->ops[] = '-crop '. (int) $width .'x'. (int) $height .'+'. (int) $x .'+'. (int) $y .'!';
+  $image->info['width'] = $width;
+  $image->info['height'] = $width;
   return TRUE;
 }
 
 function imageapi_imagemagick_image_resize(&$image, $width, $height) {
-  $args = array('resize' => '-resize '. (int) $width .'x'. (int) $height .'!');
-  $args = _imageapi_imagemagick_alter_invoke('resize', $source, $args);
-  if (!_imageapi_imagemagick_convert($image->res, $image->res, $args)) {
-    return FALSE;
-  }
+  $image->ops[] = '-resize '. (int) $width .'x'. (int) $height .'!';
   $image->info['width'] = $width;
   $image->info['height'] = $width;
   return TRUE;
 }
 
 function imageapi_imagemagick_image_rotate(&$image, $degrees, $bgcolor) {
-  $args = array(
-    'rotate' => '-rotate '. (float) $degrees,
-    'background' => '-background #'. str_pad(dechex($bg_color), 6, 0),
-  );
-  $args = _imageapi_imagemagick_alter_invoke('rotate', $source, $args);
-  return _imageapi_imagemagick_convert($image->res, $image->res, $args);
+  $image->ops[] = '-rotate '. (float) $degrees .' -background #'. str_pad(dechex($bg_color), 6, 0);
+  return TRUE;
 } 
 
 function imageapi_imagemagick_image_desaturate(&$image) {
-  $args = array('desaturate' => '-colorspace GRAY');
-  $args = _imageapi_imagemagick_alter_invoke('desaturate', $source, $args);
-  return _imageapi_imagemagick_convert($image->res, $image->res, $args);
-}
-
-/**
- * Invoke hook_imagemagick_alter().
- *
- * Implementors of hook_imagemagick_alter() should accept three parameters: $op,
- * $filepath and &$args (passed by reference), which are described below.
- *
- * @param $op
- *   String with the operation: 'resize', 'crop', 'rotate'.
- * @param $filepath
- *   String containing the path to the image that is being processed.
- * @param $args
- *   Array containing ImageMagick options.
- * @return
- *   Array of modified arguments.
- */
-function _imageapi_imagemagick_alter_invoke($op, $filepath, $args) {
-  foreach (module_implements('imagemagick_alter') as $module) {
-    $function = $module .'_imagemagick_alter'; 
-    $function($op, $filepath, $args);
-  }
-  return $args;
+  $image->ops[] = '-colorspace GRAY';
+  return TRUE;
 }
 
 /**
@@ -171,14 +135,25 @@ function _imageapi_imagemagick_convert($
   return file_exists($dest);
 }
 
-function _imageapi_imagemagick_check_path($path) {
-  return is_file($path) && is_executable($path);
+function _imageapi_imagemagick_check_path($path, $attach_error_to = FALSE) {
+  if (is_file($path)) {
+    return TRUE;
+  }
+  if ($attach_error_to) {
+    if ($open_basedir = ini_get('open_basedir')) {
+      form_set_error($attach_error_to, t("No file %file could be found. PHP's <a href='!open-basedir'>open_basedir</a> security resriction is set to %open-basedir, which may be interfearing with the attempts to locate ImageMagick.", array('%file' => $path, '%open-basedir' => $open_basedir, '!info-link' => url('http://php.net/features.safe-mode#ini.open-basedir') )));
+    }
+    else {
+      form_set_error($attach_error_to, t('The specified ImageMagic path %file does not exist.', array('%file' => $path)));
+    }
+  }
+  return FALSE;
 }
 
-function _imageapi_imagemagick_convert_exec($command_args, &$output, &$errors) {
-  $convert_path = variable_get('imageapi_imagemagick_convert', '/usr/bin/convert');
+function _imageapi_imagemagick_convert_exec($command_args, &$output, &$errors, $convert_path = '') {
+  $convert_path = !empty($convert_path) ? $convert_path : variable_get('imageapi_imagemagick_convert', '/usr/bin/convert');
   if (!_imageapi_imagemagick_check_path($convert_path)) {
-    drupal_set_message(t("ImageMagick could not be found. The admin will need to set the path on the <a href='@image-toolkit-settings'>image toolkit page</a>.", array('@image-toolkit-settings' => url('admin/settings/image-toolkit'))), 'error');
+    drupal_set_message(t("ImageMagick could not be found. The admin will need to set the path on the <a href='@image-toolkit-settings'>image toolkit page</a>.", array('@image-toolkit-settings' => url('admin/settings/imageapi/config/imageapi_imagemagick'))), 'error');
     return FALSE;
   }
 
Index: imageapi_imagick.info
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/imageapi/imageapi_imagick.info,v
retrieving revision 1.2
diff -u -p -r1.2 imageapi_imagick.info
--- imageapi_imagick.info	21 Feb 2008 11:21:05 -0000	1.2
+++ imageapi_imagick.info	14 Apr 2008 05:04:57 -0000
@@ -2,4 +2,5 @@
 name = ImageAPI Imagick
 description = Experimental Imagick PHP extension image processing support.
 package = ImageCache
-dependencies = imageapi
+dependencies[] = imageapi
+core = 6.x
Index: imageapi_imagick.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/imageapi/imageapi_imagick.module,v
retrieving revision 1.4
diff -u -p -r1.4 imageapi_imagick.module
--- imageapi_imagick.module	30 Mar 2008 23:16:45 -0000	1.4
+++ imageapi_imagick.module	14 Apr 2008 05:04:57 -0000
@@ -51,7 +51,7 @@ function imageapi_imagick_image_open($im
 
 function imageapi_imagick_image_close($image, $destination) {
   try {
-   return $image->res->writeImage($destination);
+    return $image->res->writeImage($destination);
   }
   catch(Exception $e) {
     //print_r($e);
