imagecolortransparent not making it transparent

GD and GD2 are useful libraries for creating graphics on-the-fly. Discuss your PHP GD and GD2 scripts here.

Moderators: onion2k, General Moderators

Post Reply
User avatar
anjanesh
DevNet Resident
Posts: 1679
Joined: Sat Dec 06, 2003 9:52 pm
Location: Mumbai, India

imagecolortransparent not making it transparent

Post by anjanesh »

Any idea why the transparency doesnt work ?

Code: Select all

<?php
$Font_File = "times.ttf";
$Size = 12;
$Text = "Test Text";

$Text_Coords = imagettfbbox($Size, 0, $Font_File, $Text);

$lx = abs($Text_Coords[2] - $Text_Coords[0]) + 10;
$ly = abs($Text_Coords[5] - $Text_Coords[3]) + 10;

$Image = imagecreatetruecolor($lx, $ly);

$white = imagecolorallocate($Image, 255, 255, 255);
$black = imagecolorallocate($Image, 0, 0, 0);

imagefilledrectangle($Image, 0, 0, $lx, $ly, $white);
imagecolortransparent($Image, $white);

imagettftext($Image, $Size, 0, 3, abs($Text_Coords[5] - $Text_Coords[3]) + 3, $black, $Font_File, $Text);
imagegif($Image, "test.gif");
imagedestroy($Image);
?>
Thanks
Post Reply