Index: imagemagick.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/imagemagick/imagemagick.module,v
retrieving revision 1.7
diff -u -p -r1.7 imagemagick.module
--- imagemagick.module	30 Jan 2011 18:58:52 -0000	1.7
+++ imagemagick.module	30 Jan 2011 19:34:46 -0000
@@ -72,7 +72,7 @@ function image_imagemagick_settings() {
  * Form element validation handler for image quality settings field.
  */
 function imagemagick_element_validate_quality($element, &$form_state) {
-  if ($element['#value'] < 0 || $element['#value'] > 100) {
+  if (!is_numeric($element['#value']) || $element['#value'] < 0 || $element['#value'] > 100) {
     form_error($element, t('!name must be a value between 0 and 100.', array('!name' => $element['#title'])));
   }
 }
@@ -250,6 +250,26 @@ function image_imagemagick_sharpen(stdCl
 }
 
 /**
+ * Adds a watermark to an image.
+ *
+ * @param $image
+ *   An image object.
+ * @param $watermark
+ *   A string file URI or path of the watermark image.
+ *
+ * @return
+ *   TRUE or FALSE, based on success.
+ *
+ * @see image_watermark()
+ */
+function image_imagemagick_watermark(stdClass $image, $watermark) {
+  $image->ops[] = drupal_realpath($watermark);
+  $image->ops[] = '-composite';
+  $image->ops[] = "-set 'option:compose:outside-overlay' false";
+  return TRUE;
+}
+
+/**
  * Creates an image resource from a file.
  *
  * @param $image
@@ -283,9 +303,45 @@ function image_imagemagick_save(stdClass
 }
 
 /**
+ * Get details about an image.
+ *
+ * @param $image
+ *   An image object.
+ * @return
+ *   FALSE, if the file could not be found or is not an image. Otherwise, a
+ *   keyed array containing information about the image:
+ *   - "width": Width, in pixels.
+ *   - "height": Height, in pixels.
+ *   - "extension": Commonly used file extension for the image.
+ *   - "mime_type": MIME type ('image/jpeg', 'image/gif', 'image/png').
+ *
+ * @see image_get_info()
+ */
+function image_imagemagick_get_info(stdClass $image) {
+  $details = FALSE;
+  $data = getimagesize(drupal_realpath($image->source));
+
+  if (isset($data) && is_array($data)) {
+    $extensions = array('1' => 'gif', '2' => 'jpg', '3' => 'png');
+    $extension = isset($extensions[$data[2]]) ?  $extensions[$data[2]] : '';
+    $details = array(
+      'width'     => $data[0],
+      'height'    => $data[1],
+      'extension' => $extension,
+      'mime_type' => $data['mime'],
+    );
+  }
+
+  return $details;
+}
+
+/**
  * Calls the convert executable with the specified filter.
  */
 function _imagemagick_convert($source, $dest, $args) {
+  $source = drupal_realpath($source);
+  $dest = drupal_realpath($dest);
+
   $args['quality'] = '-quality ' . escapeshellarg(variable_get('imagemagick_quality', 75));
   // To make use of ImageMagick 6's parenthetical command grouping we need to make
   // the $source image the first parameter and $dest the last.
@@ -301,7 +357,7 @@ function _imagemagick_convert($source, $
 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('imageapi imagemagick', '!errors', array('!errors' => implode('<br />', $errors)), WATCHDOG_ERROR);
+    watchdog('imagemagick', '!errors', array('!errors' => implode('<br />', $errors)), WATCHDOG_ERROR);
     return FALSE;
   }
 
