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

leafish_paul drupal-devel at drupal.org
Mon Jun 13 21:29:55 UTC 2005

Issue status update for http://drupal.org/node/24946

 Project:      Drupal
 Version:      4.6.1
 Component:    user.module
 Category:     bug reports
 Priority:     normal
 Assigned to:  Anonymous
 Reported by:  leafish_paul
 Updated by:   leafish_paul
 Status:       patch
 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?


More information about the drupal-devel mailing list