bobinindia Posted June 13, 2008 Share Posted June 13, 2008 Creating text with imagettftext When the text comes back it isn't very clean. Is there something I can do to keep the edges of the text smooth. I set the imagepng to no compression(0). $mask = imagecreatetruecolor($x,$newy); $tcolour = imagecolorallocate($mask,254,255,255); imagefilledrectangle($mask, 0, 0, $x, $newy, $tcolour); // Or draw other background. imagecolortransparent($mask, $tcolour); $color = rgb2hex2rgb($colour); $one = $color[0]; $two = $color[1]; $three = $color[2]; $txtcol = imagecolorallocate($mask, $one, $two, $three); imagettftext($mask,$fontsize, 0, 0, $y, $txtcol, $font, $txt); //stopcache is a timerelated number. $imurl = "images/transtext/".$stopcache.".png"; imagepng($mask, $imurl, 0); imagedestroy($mask); Link to comment https://forums.phpfreaks.com/topic/110039-solved-text-has-white-edges-using-imagettftext-in-transparent-png/ Share on other sites More sharing options...
bobinindia Posted June 13, 2008 Author Share Posted June 13, 2008 Solved it. By making the transparent color one of the RGB values - 1 or +1. The eye can't see it. $color = rgb2hex2rgb($colour); $one = $color[0]; $two = $color[1]; $three = $color[2]; if ($three<255){ $replace = $three +1; } else { $replace = $three - 1; } $tcolour = imagecolorallocate($mask,$one,$two,$replace); Link to comment https://forums.phpfreaks.com/topic/110039-solved-text-has-white-edges-using-imagettftext-in-transparent-png/#findComment-564656 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.