When using imagettftext with an image transparent with imagecolortransparent, the border of the text seems to blend with the original background color (black) instead of transparency, thus creating text text, as shown here:
http://i.stack.imgur.com/xLSkK.png , unlike using imagestring, here:
http://i.imgur.com/5R0gT.png
Now I'm not sure if there is a better way to combine the images so that they are created from the very beginning, or if there is another way of transparency that I do not know about. Here is the relevant PHP code I'm using:
if ($type) { $icon = imagecreatefrompng("images/" . $type . ".png"); } else { die('Invalid type. Valid types are: arcane, elysian, divine, spectral'); } $img = imagecreatetruecolor(128, 25); $black = imagecolorallocate($img, 0, 0, 0); imagecolortransparent($img, $black); imagecopymerge($img,$icon,0,0,0,0,28,25,100); imagettftext( $img, 16, 0, 30, 20, $col, $font, $input_num ); header( "Content-type: image/png" ); imagepng( $img );
source share