Index: imageapi.info
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/imageapi/imageapi.info,v
retrieving revision 1.4
diff -u -p -r1.4 imageapi.info
--- imageapi.info	23 Dec 2008 21:35:35 -0000	1.4
+++ imageapi.info	11 Mar 2009 05:41:50 -0000
@@ -1,8 +1,7 @@
 ; $Id: imageapi.info,v 1.4 2008/12/23 21:35:35 drewish Exp $
 name = ImageAPI
 description = ImageAPI supporting multiple toolkits.
-package = ImageCache
+package = ImageAPI
 core = 7.x
-php = 5.2
 files[] = imageapi.install
 files[] = imageapi.module
\ No newline at end of file
Index: imageapi.install
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/imageapi/imageapi.install,v
retrieving revision 1.7
diff -u -p -r1.7 imageapi.install
--- imageapi.install	21 Dec 2008 23:08:39 -0000	1.7
+++ imageapi.install	11 Mar 2009 05:41:50 -0000
@@ -4,7 +4,7 @@
 
 /**
  * Implementation of hook_requirements().
- */
+ *
 function imageapi_requirements($phase) {
   $requirements = array();
   // Ensure translations don't break at install time.
@@ -30,13 +30,12 @@ function imageapi_requirements($phase) {
 
   return $requirements;
 }
-function imageapi_install() {
-}
+*/
 
 /**
- * Implementation of hook_uninstall().
- *
+ * Remove the old ImageAPI toolkit setting.
  */
-function imageapi_uninstall() {
+function imageapi_update_7000() {
   variable_del('imageapi_image_toolkit');
+  return array();
 }
Index: imageapi.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/imageapi/imageapi.module,v
retrieving revision 1.25
diff -u -p -r1.25 imageapi.module
--- imageapi.module	6 Feb 2009 09:26:33 -0000	1.25
+++ imageapi.module	11 Mar 2009 05:41:50 -0000
@@ -17,257 +17,6 @@
  */
 
 /**
- * Implementation of hook_perm().
- */
-function imageapi_perm() {
-  return array(
-    'administer imageapi' => array(
-      'title' => t('Administer ImageAPI'),
-      'description' => t('Select and configure ImageAPI toolkits.'),
-    ),
-  );
-}
-
-/**
- * Implementation of hook_menu().
- */
-function imageapi_menu() {
-  $items = array();
-  $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,
-    );
-    $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' => '@name',
-          'title arguments' => array('@name' => $info['name']),
-          '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 {
-        drupal_set_message(t('ImageAPI toolkit missing settings form'), 'error');
-      }
-    }
-  }
-  return $items;
-}
-
-function imageapi_settings() {
-  $form = array();
-
-  $toolkits = imageapi_get_available_toolkits();
-
-  switch (count($toolkits)) {
-    case 0:
-      $form['imageapi_toolkits']['#markup'] = 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
-      // remaing toolkit.
-      variable_set('imageapi_image_toolkit', $toolkit);
-      $form['imageapi_image_toolkit']['#markup'] = 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) {
-        $options[$module] = $info['name'];
-      }
-      $form['imageapi_image_toolkit'] = array(
-        '#type' => 'radios',
-        '#title' => t('Select a default image processing toolkit'),
-        '#default_value' => imageapi_default_toolkit(),
-        '#options' => $options,
-        '#description' => t('This setting lets you choose which toolkit Drupal uses resizing, cropping and other image manipulations.'),
-      );
-  }
-
-  return system_settings_form($form);
-}
-
-/**
- * Return a list of available toolkits.
- *
- * @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'.
- */
-function imageapi_get_available_toolkits() {
-  static $toolkits;
-
-  if (!isset($toolkits)) {
-    $toolkits = array();
-    foreach (module_implements('imageapi_toolkit', true) as $module) {
-      $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
- *   String containing the name of the toolkit, or false if none is available.
- */
-function imageapi_default_toolkit() {
-  $toolkit = variable_get('imageapi_image_toolkit', 'imageapi_gd');
-  // Verify that the image toolkit is available.
-  if (isset($toolkit) && module_exists($toolkit)) {
-    return $toolkit;
-  }
-  // If it's not fall back to first available toolist.
-  foreach (imageapi_get_available_toolkits() as $toolkit => $info) {
-    return $toolkit;
-  }
-  return false;
-}
-
-/**
- * Scales an image to the exact width and height given. Achieves the
- * target aspect ratio by cropping the original image equally on both
- * sides, or equally on the top and bottom.  This function is, for
- * example, useful to create uniform sized avatars from larger images.
- *
- * The resulting image always has the exact target dimensions.
- *
- * @param $image
- *   An ImageAPI Image object.
- * @param $width
- *   The target width in pixels.
- * @param $height
- *   The target height in pixels.
- * @return
- *   True or false, based on success.
- */
-function imageapi_image_scale_and_crop(&$image, $width, $height) {
-  $aspect = $image->info['height'] / $image->info['width'];
-  if (empty($height)) $height = $width / $aspect;
-  if (empty($width)) $width = $height * $aspect;
-
-  $scale = max($width / $image->info['width'], $height / $image->info['height']);
-  $x = (int) round(($image->info['width'] * $scale - $width) / 2);
-  $y = (int) 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);
-  }
-  return false;
-}
-
-/**
- * Scales an image to the given width and height while maintaining aspect
- * ratio.
- *
- * The resulting image can be smaller for one or both target dimensions.
- *
- * @param $image
- *   An ImageAPI Image object.
- * @param $width
- *   The target width in pixels.
- * @param $height
- *   The target height in pixels.
- * @param $upscale
- *   Allow upscaling.
- * @return
- *   True or false, based on success.
- */
-function imageapi_image_scale(&$image, $width, $height, $upscale = false) {
-  // set width/height according to aspect ratio if either is empty;
-  $aspect = $image->info['height'] / $image->info['width'];
-  if (empty($height)) $height = $width / $aspect;
-  if (empty($width)) $width = $height * $aspect;
-
-  // Don't scale up.
-  if (!$upscale && round($width) >= $image->info['width'] && round($height) >= $image->info['height']) {
-    return true;
-  }
-
-  $aspect = $image->info['height'] / $image->info['width'];
-  if ($aspect < $height / $width) {
-    $height = $width * $aspect;
-  }
-  else {
-    $width = $height / $aspect;
-  }
-
-  // Width and height must be at least one pixel.
-  $width = max(1, (int) round($width));
-  $height = max(1, (int) round($height));
-
-  return call_user_func($image->toolkit .'_image_resize', $image, $width, $height);
-}
-
-/**
- * Resize an image to the given dimensions (ignoring aspect ratio).
- *
- * @param $source        The filepath of the source image.
- * @param $source
- *   The filepath of the source image.
- * @param $destination
- *   The file path of the destination image.
- * @param $width
- *   The target width in pixels.
- * @param $height
- *   The target height in pixels.
- * @param $toolkit
- *   An optional override of the default image toolkit.
- * @return
- *   True or false, based on success.
- */
-function imageapi_image_resize(&$image, $width, $height) {
-  $width = (int) round($width);
-  $height = (int) round($height);
-
-  return call_user_func($image->toolkit .'_image_resize', $image, $width, $height);
-}
-
-/**
- * Rotate an image by the given number of degrees.
- *
- * @param $image
- *   An imageapi image object returned by imageapi_image_open().
- * @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,
- *   0xff00ff for magenta, and 0xffffff for white.
- * @return
- *   True or false, based on success.
- */
-function imageapi_image_rotate(&$image, $degrees, $bgcolor = 0x000000) {
-  return call_user_func($image->toolkit .'_image_rotate', $image, $degrees, $bgcolor);
-}
-
-/**
  * Sharpen an image given some sharpening parameters.
  *
  * NOTE: These parameters only have an effect when Imagemagick is used.
@@ -288,102 +37,11 @@ function imageapi_image_rotate(&$image, 
  * @return
  *   True or false, based on success.
  */
-function imageapi_image_sharpen(&$image, $radius, $sigma, $amount, $threshold) {
-  return call_user_func($image->toolkit .'_image_sharpen', $image, $radius, $sigma, $amount, $threshold);
+function image_sharpen(&$image, $radius, $sigma, $amount, $threshold) {
+  return image_toolkit_invoke('sharpen', $image, array($radius, $sigma, $amount, $threshold));
 }
 
 /**
- * Crop an image to the rectangle specified by the given rectangle.
- *
- * @param $image
- *   An imageapi image object returned by imageapi_image_open().
- * @param $x
- *   The top left co-ordinate of the crop area (x axis value).
- * @param $y
- *   The top left co-ordinate of the crop area (y axis value).
- * @param $width
- *   The target width in pixels.
- * @param $height
- *   The target height in pixels.
- * @return
- *   True or false, based on success.
- */
-function imageapi_image_crop(&$image, $x, $y, $width, $height) {
-  $aspect = $image->info['height'] / $image->info['width'];
-  if (empty($height)) $height = $width / $aspect;
-  if (empty($width)) $width = $height * $aspect;
-
-  $width = (int) round($width);
-  $height = (int) round($height);
-
-  return call_user_func($image->toolkit .'_image_crop', $image, $x, $y, $width, $height);
-}
-
-/**
- * Convert an image to grayscale.
- *
- * @param $image
- *   An imageapi image object returned by imageapi_image_open().
- * @return
- *   True or false, based on success.
- */
-function imageapi_image_desaturate(&$image) {
-  return call_user_func($image->toolkit .'_image_desaturate', $image);
-}
-
-/**
- * Open an image file and return an imageapi image object. Any changes to the
- * file are not saved until imageapi_image_close() is called.
- *
- * @param $file
- *   Path to an image file.
- * @param $toolkit
- *   An optional, image toolkit name to override the default.
- * @return
- *   ImageAPI Image object or FALSE if there was a problem opening the file.
- */
-function imageapi_image_open($file, $toolkit = false) {
-  if (!$toolkit) {
-    $toolkit = imageapi_default_toolkit();
-  }
-  if ($toolkit) {
-    $image = new stdClass();
-    $image->source = $file;
-    $image->info = image_get_info($file);
-    $image->toolkit = $toolkit;
-    if ($image = call_user_func($image->toolkit .'_image_open', $image)) {
-      return $image;
-    }
-  }
-  watchdog('imageapi', 'ImageAPI failed to open %file with %toolkit', array('%file' => $file, '%toolkit' => $toolkit), WATCHDOG_WARNING);
-  return false;
-}
-
-/**
- * Close the image and save the changes to a file.
- *
- * @param $image
- *   imageAPI image object.
- *
- * @param $destination
- *   Destination path where the image should be saved. If it is empty the
- *   original image file will be overwritten.
- */
-function imageapi_image_close($image, $destination = '') {
-  if (empty($destination)) {
-    $destination = $image->source;
-  }
-  if ($return = call_user_func($image->toolkit .'_image_close', $image, $destination)) {
-    if (@chmod($destination, 0664)) {
-      return $return;
-    }
-    watchdog('imageapi', 'Could not set permissons on destination file: %file', array('%file' => $destination));
-  }
-  return false;
-}
-
-
-/**
  * Convert a hex string to its RGBA (Red, Green, Blue, Alpha) integer
  * components.
  *
Index: imageapi_gd.info
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/imageapi/imageapi_gd.info,v
retrieving revision 1.5
diff -u -p -r1.5 imageapi_gd.info
--- imageapi_gd.info	23 Dec 2008 21:35:35 -0000	1.5
+++ imageapi_gd.info	11 Mar 2009 05:41:50 -0000
@@ -1,7 +1,9 @@
 ; $Id: imageapi_gd.info,v 1.5 2008/12/23 21:35:35 drewish Exp $
 name = ImageAPI GD2
-description = Uses PHP's built-in GD2 image processing support.
-package = ImageCache
+description = Provides additional operations for PHP's built-in GD2 image processing support.
+package = ImageAPI
 core = 7.x
 files[] = imageapi_gd.install
-files[] = imageapi_gd.module
\ No newline at end of file
+files[] = imageapi_gd.module
+files[] = imagefilter.inc
+files[] = imagerotate.inc
\ No newline at end of file
Index: imageapi_gd.install
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/imageapi/imageapi_gd.install,v
retrieving revision 1.8
diff -u -p -r1.8 imageapi_gd.install
--- imageapi_gd.install	1 Aug 2008 18:52:22 -0000	1.8
+++ imageapi_gd.install	11 Mar 2009 05:41:50 -0000
@@ -73,8 +73,10 @@ function imageapi_gd_requirements($phase
 }
 
 /**
- * Implementation of hook_uninstall().
+ * Remove the old JPEG quality setting.
  */
-function imageapi_gd_uninstall() {
+function imageapi_gd_update_7000() {
   variable_del('imageapi_jpeg_quality');
+  return array();
 }
+
Index: imageapi_gd.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/imageapi/imageapi_gd.module,v
retrieving revision 1.16
diff -u -p -r1.16 imageapi_gd.module
--- imageapi_gd.module	13 Feb 2009 02:29:01 -0000	1.16
+++ imageapi_gd.module	11 Mar 2009 05:41:50 -0000
@@ -5,203 +5,32 @@
  * GD2 toolkit functions
  */
 
-/**
- * Implementation of hook_imageapi_toolkit().
- *
- * this hook only gets called to see is a module implements the imageapi hooks...
- */
-function imageapi_gd_imageapi_toolkit() {
-}
-
-
-/**
- * Settings form for the toolkit.
- */
-function imageapi_gd_settings_form() {
-  $form['imageapi_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('imageapi_jpeg_quality', 75),
-    '#field_suffix' => '%',
-  );
-  $form['imageapi_crop_background'] = array(
-    '#type' => 'textfield',
-    '#title' => t('Crop background'),
-    '#description' => t('Hex string specifying the background color to use when cropping images. If not provided, will use the default. Examples: "ABC", "ABCD", "AABBCC", "AABBCCDD".'),
-    '#size' => 10,
-    '#maxlength' => 8,
-    '#default_value' => variable_get('imageapi_crop_background', ''),
-    '#field_prefix' => '#',
-  );
-  return system_settings_form($form);
-}
-
-function imageapi_gd_image_open($image) {
-  if ($image->res =  _gd_open($image->source, $image->info['extension'])) {
-    return $image;
-  }
-  return false;
-}
-
-function imageapi_gd_image_close($image, $destination) {
-  return _gd_close($image->res, $destination, $image->info['extension']);
-}
-
-function imageapi_gd_image_crop(&$image, $x, $y, $width, $height) {
-  // Create an image with the new width and height.
-  $res = _gd_create_tmp($image, $width, $height);
-
-  // Fill the background color if desired.
-  $background = variable_get('imageapi_crop_background', '');
-  if (!empty($background)) {
-    $background = imageapi_hex2rgba($background);
-    $background = imagecolorallocatealpha($res, $background[0], $background[1], $background[2], $background[3]);
-    imagefill($res, 0, 0, $background);
-  }
-
-  // Copy the source image to our new destination image. We use
-  // $image->info['width] instead of $width because we are copying
-  // using the source image's width and height, not the destination
-  // width and height.
-  if (!imagecopyresampled($res, $image->res, -$x, -$y, 0, 0, $image->info['width'], $image->info['height'], $image->info['width'], $image->info['height'])) {
-    return false;
-  }
-
-  // destroy the original image and return the modified image.
-  imagedestroy($image->res);
-  $image->res = $res;
-  $image->info['width'] = $width;
-  $image->info['height'] = $height;
-  return true;
-}
-
-function imageapi_gd_image_resize(&$image, $width, $height) {
-
-  $res = _gd_create_tmp($image, $width, $height);
-
-  if (!imagecopyresampled($res, $image->res, 0, 0, 0, 0, $width, $height, $image->info['width'], $image->info['height'])) {
-    return false;
-  }
-  imagedestroy($image->res);
-  // update image object
-  $image->res = $res;
-  $image->info['width'] = $width;
-  $image->info['height'] = $height;
-  return true;
-}
-
-function imageapi_gd_image_rotate(&$image, $degrees, $bgcolor) {
-  $res = imagerotate($image->res, 360 - $degrees, $bgcolor);
-  imagedestroy($image->res);
-  $image->res = $res;
-  $image->info['width'] = imagesx($res);
-  $image->info['height'] = imagesy($res);
-  return true;
-} 
-
-function imageapi_gd_image_sharpen(&$image, $radius, $sigma, $amount, $threshold) {
+function imageapi_gd_image_sharpen(stdImage $image, $radius, $sigma, $amount, $threshold) {
   $threshold = round($threshold * 255);
-  $image->res = _gd_unsharp_mask($image->res, $radius, $sigma, $amount, $threshold);
-  return true;
-}
-
-function imageapi_gd_image_desaturate(&$image) {
-  return imagefilter($image->res, IMG_FILTER_GRAYSCALE);
-}
-
-/**
- * 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('imageapi_jpeg_quality', 75));
-  }
-  else {
-    return $close_func($res, $destination);
-  }
+  $image->resource = imageapi_gd_unsharp_mask($image->resource, $radius, $sigma, $amount, $threshold);
+  return TRUE;
 }
 
+// Provide a implementation of imagerotate() and imagefilter() if they
+// weren't compiled into PHP.
 if (!function_exists('imagerotate')) {
   require_once drupal_get_path('module', 'imageapi') .'/imagerotate.inc';
 }
-
 if (!function_exists('imagefilter')) {
   require_once drupal_get_path('module', 'imageapi') .'/imagefilter.inc';
 }
 
-
-/** 
- * create a true color image preserving transparency from a provided
- * image.
- * @todo: add bgcolor setting to add a default background color.
- */
-function _gd_create_tmp($image, $width, $height) { 
-  $res = imagecreatetruecolor($width, $height);
-
-  // Alpha settings have no negative effect on jpegs, 
-  // but do help them support layering better for in-between steps.
-  imagealphablending($res, FALSE);
-  imagesavealpha($res, TRUE);
-  
-  if ($image->info['extension'] == 'gif' || $image->info['extension'] == 'jpg') {
-    // grab transparent color index from src.
-    $transparent = imagecolortransparent($image->res);
-
-    // if indexed transparency, lets preserve it.
-    if ($transparent >= 0) {
-      // get color(r,g,b) for index;
-      $color = imagecolorsforindex($image->res, $transparent);
-      // allocate to new image and get new index.
-      $transparent =  (isset($color['alpha'])) 
-        ? imagecolorallocatealpha($res, $color['red'], $color['green'], $color['blue'], $color['alpha'])
-        : imagecolorallocate($res, $color['red'], $color['green'], $color['blue']);
- 
-      $transparent = imagecolorallocate($res,  $transparent['red'], $transparent['green'],  $transparent['blue']);
-      // flood with our new transparent color.
-      imagefill($res, 0, 0, $transparent);
-      // tell the new image which color is transparent.
-      imagecolortransparent($res, $transparent);
-    }
-  }
-  elseif ($image->info['extension'] == 'png') {
-    $transparency = imagecolorallocatealpha($res, 0, 0, 0, 127);
-    imagefill($res, 0, 0, $transparency);
-  }
-  return $res;
-}
-
 /**
  * $sigma is currently unused for _gd_sharp_mask due to 3x3 convolution matrix limit.
  * we should explore properly implementing sigma.
  */
-function _gd_unsharp_mask($img, $radius, $sigma, $amount, $threshold)    {  
+function imageapi_gd_unsharp_mask($img, $radius, $sigma, $amount, $threshold)    {
 
   ////////////////////////////////////////////////////////////// 
   ////   
   ////                  Unsharp Mask for PHP - version 2.1.1   
   ////   
-  ////    Unsharp mask algorithm by Torstein Hønsi 2003-07.   
+  ////    Unsharp mask algorithm by Torstein Hï¿½nsi 2003-07.   
   ////             thoensi_at_netcom_dot_no.   
   ////               Please leave this notice.   
   ////   
Index: imageapi_imagemagick.info
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/imageapi/imageapi_imagemagick.info,v
retrieving revision 1.4
diff -u -p -r1.4 imageapi_imagemagick.info
--- imageapi_imagemagick.info	23 Dec 2008 21:35:35 -0000	1.4
+++ imageapi_imagemagick.info	11 Mar 2009 05:41:50 -0000
@@ -1,6 +1,6 @@
 ; $Id: imageapi_imagemagick.info,v 1.4 2008/12/23 21:35:35 drewish Exp $
 name = ImageAPI ImageMagick
 description = Command Line ImageMagick support.
-package = ImageCache
+package = ImageAPI
 core = 7.x
 files[] = imageapi_imagemagick.module
\ No newline at end of file
Index: imageapi_imagemagick.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/imageapi/imageapi_imagemagick.module,v
retrieving revision 1.20
diff -u -p -r1.20 imageapi_imagemagick.module
--- imageapi_imagemagick.module	12 Feb 2009 16:41:00 -0000	1.20
+++ imageapi_imagemagick.module	11 Mar 2009 05:41:50 -0000
@@ -5,19 +5,23 @@
  * ImageMagick toolkit functions
  */
 
+
 /**
- * Implementation of hook_imageapi_toolkit().
- *
- * this hook only gets called to see is a module implements the imageapi hooks...
+ * Implementation of hook_image_toolkits().
  */
-function imageapi_imagemagick_imageapi_toolkit() {
+function imageapi_imagemagick_image_toolkits() {
+  return array(
+    'imageapi_imagemagick' => array(
+      'title' => t('ImageMagick toolkit'),
+      'available' => TRUE,
+    ),
+  );
 }
 
-
 /**
  * Settings form for the toolkit.
  */
-function imageapi_imagemagick_settings_form() {
+function image_imageapi_imagemagick_settings() {
   $form['imageapi_imagemagick_quality'] = array(
     '#type' => 'textfield',
     '#title' => t('Compression Quality'),
@@ -32,22 +36,17 @@ function imageapi_imagemagick_settings_f
   $form['imageapi_imagemagick_binary'] = array(
     '#type' => 'fieldset',
     '#title' => t('ImageMagick Binary'),
-    '#collapsible' => false,
+    '#collapsible' => FALSE,
     '#description' => t('ImageMagick is a standalone program used to manipulate images. To use it, it must be installed on your server and you need to know where it is located. If you are unsure of the exact path consult your ISP or server administrator.'),
   );
-
-  $form['imageapi_imagemagick_binary']['version'] = array('#weight' => -1);
-  $form['imageapi_imagemagick_binary']['#after_build'] = array('_imageapi_imagemagick_build_version');
-
   $form['imageapi_imagemagick_binary']['imageapi_imagemagick_convert'] = array(
     '#type' => 'textfield',
     '#title' => t('Path to the "convert" binary'),
     '#default_value' => variable_get('imageapi_imagemagick_convert', '/usr/bin/convert'),
-    '#required' => true,
+    '#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>'),
     '#element_validate' => array('imageapi_imagemagick_validate_path'),
   );
-
   $form['imageapi_imagemagick_binary']['imageapi_imagemagick_debugging'] = array(
     '#type' => 'checkbox',
     '#title' => t('Display debugging information'),
@@ -55,8 +54,10 @@ function imageapi_imagemagick_settings_f
     '#description' => t('Checking this option will display the ImageMagick commands and output to users with the <em>administer site configuration</em> permission.'),
     '#weight' => 2,
   );
+  $form['imageapi_imagemagick_binary']['version'] = array('#weight' => -1);
+  $form['imageapi_imagemagick_binary']['#after_build'] = array('_imageapi_imagemagick_build_version');
 
-  return system_settings_form($form);
+  return $form;
 }
 
 function _imageapi_imagemagick_build_version($form_element, $form_state) {
@@ -82,12 +83,12 @@ function _imageapi_imagemagick_build_ver
 }
 
 function imageapi_imagemagick_validate_path($element) {
-  if ($errors = _imageapi_imagemagick_check_path($element['#value'])) {
+  if ($element['#post'] == 'imageapi_imagemagick' && $errors = _imageapi_imagemagick_check_path($element['#value'])) {
     form_set_error($element['#parents'][0], implode('<br />', $errors));
     //form_set_value($element['#parents'][0], variable_get('imageapi_imagemagick_convert', '/usr/bin/convert'));
-    return false;
+    return FALSE;
   }
-  return true;
+  return TRUE;
 }
 
 function imageapi_imagemagick_quality_element_validate($element) {
@@ -96,49 +97,54 @@ function imageapi_imagemagick_quality_el
   }
 }
 
-function imageapi_imagemagick_image_open($image) {
+function image_imageapi_imagemagick_load(stdClass $image) {
   $image->ops = array();
   return $image;
 }
 
-function imageapi_imagemagick_image_close($image, $dst) {
-  return _imageapi_imagemagick_convert($image->source, $dst, $image->ops);
+function image_imageapi_imagemagick_save(stdClass $image, $destination) {
+  return _imageapi_imagemagick_convert($image->source, $destination, $image->ops);
 }
 
-function imageapi_imagemagick_image_crop(&$image, $x, $y, $width, $height) {
+function image_imageapi_imagemagick_crop(stdClass $image, $x, $y, $width, $height) {
   $image->ops[]  = '-crop '. (int) $width .'x'. (int) $height .'+'. (int) $x .'+'. (int) $y .'!';
   $image->info['width'] = $width;
   $image->info['height'] = $height;
-  return true;
+  return TRUE;
 }
 
-function imageapi_imagemagick_image_resize(&$image, $width, $height) {
+function image_imageapi_imagemagick_resize(stdClass $image, $width, $height) {
   $image->ops[] = '-resize '. (int) $width .'x'. (int) $height .'!';
   $image->info['width'] = $width;
   $image->info['height'] = $height;
-  return true;
+  return TRUE;
 }
 
-function imageapi_imagemagick_image_rotate(&$image, $degrees, $bgcolor) {
-  if (is_int($bgcolor)) {
-    $bgcolor = '#'. str_pad(dechex($bgcolor), 6, 0);
+function image_imageapi_imagemagick_rotate(stdClass $image, $degrees, $background = NULL) {
+  if (is_null($background)) {
+    $image->ops[] = ' -rotate '. (float) $degrees;
   }
   else {
-    $bgcolor = str_replace('0x', '#', $bgcolor);
+    if (is_int($bgcolor)) {
+      $bgcolor = '#'. str_pad(dechex($bgcolor), 6, 0);
+    }
+    else {
+      $bgcolor = str_replace('0x', '#', $bgcolor);
+    }
+    $image->ops[] = '-background '. escapeshellarg($bgcolor) .' -rotate '. (float) $degrees;
   }
-  $image->ops[] = '-background '. escapeshellarg($bgcolor) .' -rotate '. (float) $degrees;
-  return true;
+  return TRUE;
 }
 
-function imageapi_imagemagick_image_sharpen(&$image, $radius, $sigma, $amount, $threshold) {
+function image_imageapi_imagemagick_sharpen(stdClass $image, $radius, $sigma, $amount, $threshold) {
   $unsharp_arg = $radius .'x'. $sigma .'+'. $amount/100 .'+'. $threshold;
   $image->ops[] = '-unsharp '. $unsharp_arg;
-  return true;
+  return TRUE;
 }
 
-function imageapi_imagemagick_image_desaturate(&$image) {
+function image_imageapi_imagemagick_desaturate(stdClass $image) {
   $image->ops[] = '-colorspace GRAY';
-  return true;
+  return TRUE;
 }
 
 /**
@@ -152,7 +158,7 @@ function _imageapi_imagemagick_convert($
   $command = escapeshellarg($source) .' '. implode(' ', $args) .' '. escapeshellarg($dest);
 
   if (0 != _imageapi_imagemagick_convert_exec($command, $output, $errors)) {
-    return false;
+    return FALSE;
   }
   return file_exists($dest);
 }
@@ -166,7 +172,7 @@ function _imageapi_imagemagick_check_pat
     $errors[] = t('The specified ImageMagick path %file is not executable.', array('%file' => $path));
   }
   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')));
+    $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')));
   }
   return $errors;
 }
@@ -175,7 +181,7 @@ function _imageapi_imagemagick_convert_e
   $convert_path = variable_get('imageapi_imagemagick_convert', '/usr/bin/convert');
   if ($errors = _imageapi_imagemagick_check_path($convert_path)) {
     watchdog('imageapi imagemagick', '!errors', array('!errors' => implode('<br />', $errors)), WATCHDOG_ERROR);
-    return false;
+    return FALSE;
   }
 
   if (strstr($_SERVER['SERVER_SOFTWARE'], 'Win32') || strstr($_SERVER['SERVER_SOFTWARE'], 'IIS')) {
@@ -203,7 +209,7 @@ function _imageapi_imagemagick_convert_e
     }
 
     // Display debugging information to authorized users.
-    if (variable_get('imageapi_imagemagick_debugging', false) && user_access('administer site configuration')) {
+    if (variable_get('imageapi_imagemagick_debugging', FALSE) && user_access('administer site configuration')) {
       drupal_set_message(t('ImageMagick command: @command', array('@command' => $convert_path .' '. $command_args)));
       drupal_set_message(t('ImageMagick output: @output', array('@output' => $output)));
     }
@@ -217,5 +223,5 @@ function _imageapi_imagemagick_convert_e
     fclose($pipes[2]);
     return proc_close($h);
   }
-  return false;
+  return FALSE;
 }
