diff options
Diffstat (limited to 'classes')
-rwxr-xr-x | classes/User_group.php | 29 |
1 files changed, 22 insertions, 7 deletions
diff --git a/classes/User_group.php b/classes/User_group.php index 522dd8143..092c1bc34 100755 --- a/classes/User_group.php +++ b/classes/User_group.php @@ -132,14 +132,29 @@ class User_group extends Memcached_DataObject } $image_dest = imagecreatetruecolor($size, $size); + + if ($type == IMAGETYPE_GIF || $type == IMAGETYPE_PNG) { + + $transparent_idx = imagecolortransparent($image_src); + + if ($transparent_idx >= 0) { + + $transparent_color = imagecolorsforindex($image_src, $transparent_idx); + $transparent_idx = imagecolorallocate($image_dest, $transparent_color['red'], $transparent_color['green'], $transparent_color['blue']); + imagefill($image_dest, 0, 0, $transparent_idx); + imagecolortransparent($image_dest, $transparent_idx); + + } elseif ($type == IMAGETYPE_PNG) { + + imagealphablending($image_dest, false); + $transparent = imagecolorallocatealpha($image_dest, 0, 0, 0, 127); + imagefill($image_dest, 0, 0, $transparent); + imagesavealpha($image_dest, true); + + } + } - $background = imagecolorallocate($image_dest, 0, 0, 0); - ImageColorTransparent($image_dest, $background); - imagealphablending($image_dest, false); - - imagecopyresized($image_dest, $image_src, - 0, 0, 0, 0, - $size, $size, $info[0], $info[1]); + imagecopyresampled($image_dest, $image_src, 0, 0, 0, 0, $size, $size, $info[0], $info[1]); $outname = common_avatar_filename($this->id, image_type_to_extension($type), |