Making Text [not the background] transparent
| From: | Graham Anderson | Date: | Wed, 31 Aug 2005 17:09:39 +0000 |
| Subject: | Making Text [not the background] transparent | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-221661@lists.php.net to get a copy of this message | ||
How do I make the text transparent over the background ?
In my web app, I want to to put a layer BEHIND the image to control the color of the php-created text
So, the layer color in the web app shows thru the text php creates....
Would like to use alpha transparency so the color looks clean :)
how would I amend the below script to do this ?
many thanks
g
header("Content-type:".$mime); //$mime = image/png
$im = imagecreatetruecolor(200, 16); //use to draw a text box
imageAlphaBlending($im, true);
imageSaveAlpha($im, true);
$left = 5; //add a little pad to the left edge$color = imagecolorallocate($im, 255, 255, 255); $fontSize = 11; // choose a font $fontPath = "/home/siren/fonts/"; $defaultFont = "tahomabd.ttf"; $fontName = "arial.ttf"; $font = $fontPath.$fontName ; if (! file_exists($font)) { $font = $fontPath.$defaultFont ; } $text= "background color shows through the text" // Add the text imagettftext($im, $fontSize, 0, 10, 13, $color, $font, $text); imagepng($im); readfile($im); imagedestroy($im);