diff options
author | Sean Murphy <sgmurphy@gmail.com> | 2009-02-04 14:44:12 -0500 |
---|---|---|
committer | Sean Murphy <sgmurphy@gmail.com> | 2009-02-04 14:44:12 -0500 |
commit | 5c880bc6cc34793c2eb87697e4ca66ca2e6e12f9 (patch) | |
tree | 3d9eeaf897463f35ed283fcd0111b8ea40a1f575 /classes/User_group.php | |
parent | 22c806a15a957c300cb047cb42e8f5c49d47afa9 (diff) |
Fix for #1057; group logo transparecy (and pixilation)
Diffstat (limited to 'classes/User_group.php')
-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), |