Page 1 of 1

Transparency in GD2 not working..

Posted: Fri Jul 14, 2006 1:35 am
by daedalus__

Code: Select all

function CreateHeader($text)
{
   $image		= imagecreatetruecolor(200, 21) or die("Could not create image.");
   $text_color	= imagecolorallocate($image, 60, 21, 0);
   $bg_color	= imagecolorallocate($image, 0, 0, 255);
   $background	= imagefilledrectangle($image, 0, 0, 200, 21, $bg_color);
	
   imagecolortransparent($image, $bg_color);
   imagettftext($image, 18, 0, 5, 18, $text_color, 'goudosb.ttf', $text);
   imagegif($image);
   imagedestroy($image);
}

header('Content-type: image/gif');
CreateHeader($_GET['text']);
Is there any reason why the following code should not work?

Try it out, the blue won't be transparent.

Posted: Fri Jul 14, 2006 6:08 am
by onion2k
Transparent images can be a pain in the bum .. I always use imagecreatetruecolortransparent() .. http://www.phpgd.com/scripts.php?script=27