Possible Duplicate:
Remove white background from an image and make it transparent
I currently have a code that removes the white background from an image, it looks like this:
function transparent_background($filename, $color)
{
$img = imagecreatefrompng($_SERVER['DOCUMENT_ROOT'].'/'.$filename);
$colors = explode(',', $color);
$remove = imagecolorallocate($img, $colors[0], $colors[1], $colors[2]);
imagecolortransparent($img, $remove);
imagepng($img, $_SERVER['DOCUMENT_ROOT'].'/'.$filename);
}
transparent_background('test.png', '255,255,255');
However, once it exports, the edge is very rough. This is what it looks like (note that this is just part of my image):
http://img211.imageshack.us/img211/97/2125c773e32c432b91e1127.png
I added a black background behind that image to show the edge better. So is there a way that I can add a line to the function or edit the function so the edges are smoother/anti-aliased? Thanks!