c_shelswell Posted August 2, 2008 Share Posted August 2, 2008 Hi I'm trying to create a text image with a transparent background. I can create the image no problem but seem to get stuck with the transparent background it just keeps making it a solid colour. Here's my code: function createHeadings($string, $bckCol, $txtCol, $path, $name, $dlcLocation, $fontSize) { $font = './fonts/arialbd.ttf'; //(FONT_SIZE, ANGLE, FONT, $STRING) $bb = imagettfbbox($fontSize, 0, $font, $string); $w = abs($bb[4] - $bb[0]); $h = abs($bb[5] - $bb[1]); $h = 11; $im = imagecreatetruecolor($w + 5, $h+; $textColour = imagecolorallocate($im, $txtCol[0], $txtCol[1], $txtCol[2]); $backColour = imagecolorallocatealpha($im, $bckCol[0], $bckCol[1], $bckCol[2], 0); imagefilledrectangle($im, 0, 0, $w+5, 29, $backColour); // (IMAGE, FONT_SIZE, ANGLE, X-START, Y-START, COLOUR, FONT, TEXT imagettftext($im, $fontSize, 0, 01, $h+2, $textColour, $font, $string); $finalPath = "../$dlcLocation/$path/$name"; imagegif($im, $finalPath, 100); echo "<img src='$finalPath'><p />"; imagedestroy($im); } from what i could see in the manual I could just use imagecolorallocatealpha? Thanks for any help Link to comment https://forums.phpfreaks.com/topic/117823-having-trouble-with-imagecolorallocatealpha/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.