Index: imagefield.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/imagefield/imagefield.module,v
retrieving revision 1.30.2.6.2.22
diff -u -p -r1.30.2.6.2.22 imagefield.module
--- imagefield.module	14 Jul 2007 22:36:41 -0000	1.30.2.6.2.22
+++ imagefield.module	9 Oct 2007 10:42:25 -0000
@@ -278,6 +278,12 @@ function imagefield_widget_settings($op,
         '#description' => 
         t('The maximum allowed image size expressed as WIDTHxHEIGHT (e.g. 640x480). Set to 0 for no restriction.')
       );
+      $form['restrict_resolution'] = array (
+        '#type' => 'checkbox',
+        '#title' => t('Restrict images to one resolution'),
+        '#default_value' => $widget['restrict_resolution'] ? $widget['restrict_resolution'] : 0,
+        '#description' => t('Require uploaded images to match the maximum resolution.'),
+      );
       $form['image_path'] = array(
         '#type' => 'textfield', 
         '#title' => t('Image path'), 
@@ -353,7 +359,7 @@ function imagefield_widget_settings($op,
       break;
 
     case 'save':
-      return array('max_resolution', 'image_path', 'file_extensions', 'custom_alt', 'custom_title', 'use_default_image', 'default_image');
+      return array('max_resolution', 'restrict_resolution', 'image_path', 'file_extensions', 'custom_alt', 'custom_title', 'use_default_image', 'default_image');
   }
 }
 
@@ -743,6 +749,18 @@ function _imagefield_widget_upload_valid
     form_set_error($field['field_name'], t('Mime Type mismatch. Only image files may be upload. You uploaded a file with mime type: %mime', array('%mime' => $file['filemime'])));
     $valid = FALSE;
   }
+
+  // Are we restricted to one resolution?
+  if ($field['widget']['restrict_resolution']) {
+    $info = image_get_info($file['filepath']);
+    list($width, $height) = explode('x', $field['widget']['max_resolution']);
+    // Does the resolution not match the restriction?
+    if ($width != $info['width'] || $height != $info['height']) {
+      form_set_error($field['field_name'], t('An image resolution of %restricted_width x %restricted_height pixels is required. Uploaded image has a pixel resolution of %uploaded_width x %uploaded_height.', array('%restricted_width' => $width, '%restricted_height' => $height, '%uploaded_width' => $info['width'], '%uploaded_height' => $info['height'])));
+      $valid = FALSE;
+    }
+  }
+
   return $valid;
 }
