I have this code:
$im = imagecreatetruecolor(70, 25);
$white = imagecolorallocate($im, 255, 255, 255);
$grey = imagecolorallocate($im, 128, 128, 128);
$black = imagecolorallocate($im, 0, 0, 0);
imagecolortransparent($im, imagecolorallocate($im, 0,0,0));
$font = 'font.ttf';
imagettftext($im, 20, 0, 3, 22, $white, $font, $randomnr);
header("Expires: Wed, 1 Jan 1997 00:00:00 GMT");
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
header ("Content-type: image/png");
imagepng($im);
imagedestroy($im);
And like I said in the title it creates some black edges around the text.
I also tried with the imagealphablending
/imagesavealpha
and i've had the same result(i used the white text on transparent background so that you can see what i am talking about):
UPDATE: the solution is:
$im = imagecreatetruecolor(70, 25);
$font = 'font.ttf';
//antialiasing:
$almostblack = imagecolorallocate($im,254,254,254);
imagefill($im,0,0,$almostblack);
$black = imagecolorallocate($im,0,0,0);
imagecolortransparent($im,$almostblack);
imagettftext($im, 20, 0, 3, 22, $white, $font, $randomnr);
...