[drupal-devel] [bug] Always resizing user pictures breaks transparency?

praseodymium drupal-devel at drupal.org
Wed Aug 3 20:37:01 UTC 2005

Issue status update for 
Post a follow up: 

 Project:      Drupal
 Version:      cvs
 Component:    user.module
 Category:     bug reports
 Priority:     normal
 Assigned to:  Anonymous
 Reported by:  leafish_paul
 Updated by:   praseodymium
 Status:       patch (code needs review)

And the description texts say you may not upload a picture larger than
that. I even think the size of the resized picture isn't checked...


Previous comments:

Mon, 13 Jun 2005 21:29:41 +0000 : leafish_paul

Attachment: http://drupal.org/files/issues/user.module_tweaked_picture_resizing.patch (1.47 KB)

I recently noticed that when uploading transparent user pictures to a
Drupal site, the transparent colour is lost (replaced with black). I
think its to do with image_size()... but I noticed the slightly odd
logic in user.module:

 if (!$info || !$info['extension']) {
    form_set_error('picture', t('The uploaded file was not an
  else if (image_get_toolkit()) {
    image_scale($file->filepath, $file->filepath, $maxwidth,
  else if (filesize($file->filepath) >
(variable_get('user_picture_file_size', '30') * 1000)) {
    form_set_error('picture', t('The uploaded image is too large;
the maximum file size is %size kB.', array('%size' =>
variable_get('user_picture_file_size', '30'))));
  else if ($info['width'] > $maxwidth || $info['height'] >
$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'))));

So, the image is always scaled if an image toolkit is found. The
attached patch /only/ scales user pictures if they are too large, and
will still show an error if a toolkit is not found.

I'm aware that there may be a better patch for image.inc to retain
scaled image transparency?


Wed, 27 Jul 2005 16:26:38 +0000 : leafish_paul

Still applies to head.

More information about the drupal-devel mailing list