Index: filefield.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/filefield/filefield.module,v
retrieving revision 1.227
diff -u -r1.227 filefield.module
--- filefield.module	6 Dec 2010 04:42:09 -0000	1.227
+++ filefield.module	6 Dec 2010 05:25:51 -0000
@@ -791,6 +791,8 @@
   // Check first that the file is an image.
   if ($info = image_get_info($file->filepath)) {
     if ($maximum_dimensions) {
+      $resized = FALSE;
+
       // Check that it is smaller than the given dimensions.
       if ($info['width'] > $max_width || $info['height'] > $max_height) {
         $ratio = min($max_width/$info['width'], $max_height/$info['height']);
@@ -807,20 +809,23 @@
           $res = imageapi_image_open($file->filepath);
           imageapi_image_scale($res, $max_width, $max_height);
           imageapi_image_close($res, $file->filepath);
+          $resized = TRUE;
         }
         // Try to resize the image to fit the dimensions.
         elseif (image_get_toolkit() && @image_scale($file->filepath, $file->filepath, $max_width, $max_height)) {
-          drupal_set_message(t('The image was resized to fit within the maximum allowed dimensions of %dimensions pixels.', array('%dimensions' => $maximum_dimensions)));
-
-          // Clear the cached filesize and refresh the image information.
-          clearstatcache();
-          $info = image_get_info($file->filepath);
-          $file->filesize = $info['file_size'];
+          $resized = TRUE;
         }
         else {
           $errors[] = t('The image is too large; the maximum dimensions are %dimensions pixels.', array('%dimensions' => $maximum_dimensions));
         }
       }
+
+      // Clear the cached filesize and refresh the image information.
+      if ($resized) {
+        drupal_set_message(t('The image was resized to fit within the maximum allowed dimensions of %dimensions pixels.', array('%dimensions' => $maximum_dimensions)));
+        clearstatcache();
+        $file->filesize = filesize($file->filepath);
+      }
     }
 
     if ($minimum_dimensions && empty($errors)) {
