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

leafish_paul drupal-devel at drupal.org
Wed Jul 27 16:26:41 UTC 2005


Issue status update for 
http://drupal.org/node/24946
Post a follow up: 
http://drupal.org/project/comments/add/24946

 Project:      Drupal
-Version:      4.6.1
+Version:      cvs
 Component:    user.module
 Category:     bug reports
 Priority:     normal
 Assigned to:  Anonymous
 Reported by:  leafish_paul
 Updated by:   leafish_paul
 Status:       patch

Still applies to head.




leafish_paul



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:



<?php
 if (!$info || !$info['extension']) {
    form_set_error('picture', t('The uploaded file was not an
image.'));
  }
  else if (image_get_toolkit()) {
    image_scale($file->filepath, $file->filepath, $maxwidth,
$maxheight);
  }
  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