I am unable to upload any image onto my account page. The following error is always returned, even when the image dimensions are well below the maximum and minimum values.

"The uploaded image is too large; the maximum dimensions are 85x85 pixels."

Comments

jasono’s picture

Oh, and here is why. user_validate_picture in user.module contains the following statement:

else if (!image_scale($file->filepath, $file->filepath, $maxwidth, $maxheight)) {
    form_set_error('picture', t('The uploaded image is too large; the maximum dimensions are %dimensions pixels.', array('%dimensions' => variable_get('user_picture_dimensions', '85x85'))));
  }

The image_scale function, in image.inc, contains the following statement:

// don't scale up
  if ($width > $info['width'] && $height > $info['height']) {
    return false;
  } 

The problem is that the image_scale function is returning false if the image is already smaller than the specified maximum and minimum sizes, but then this is causing the code in user_validate_picture to drop into the error code routine.

jasono’s picture

I changed the return value to true instead of false, and this fixes the problem. I'm not sure if any other code is using the image_scale function however, so I'm not sure what the impact of using this as a fix would be. This is still an open issue in the latest CVS code.

function image_scale($source, $destination, $width, $height) {
  $info = image_get_info($source);

  // don't scale up
  if ($width > $info['width'] && $height > $info['height']) {
    return true;
  }
jasono’s picture

Seems to now be fixed in CVS version.

Anonymous’s picture