Basically I am looking for a way to write dynamic text on top of a GIF [preferably via PHP GD.] But I can't seem to get these two functions to play nice.
For reference: imagecreatefromgif & imagettftext
function load_gif($imgname)
{
$im = @imagecreatefromgif($imgname);
if(!$im)
{
$im = imagecreatetruecolor(150,30);
$bgc = imagecolorallocate($im,255,255,255);
$tc = imagecolorallocate($im,0,0,0);
imagefilledrectangle($im,0,0,150,30,$bgc);
imagestring($im,1,5,5,'Error loading ' . $imgname,$tc);
}
return $im;
}
if ($_GET['color'] == 'red')
{
header('Content-Type:image/gif');
//$img = imagecreatetruecolor(51,32); // THIS IS NEEDED FOR TEXT TO SHOW
$img = load_gif('map-bubble-' . $_GET['color'] . '.gif');
$black = imagecolorallocate($img,0,0,0);
$white = imagecolorallocate($img,255,255,255);
imagefilledrectangle($img,0,0,51,32,$black);
imagettftext($img,14,0,0,0,$white,'../arial.ttf','test');
imagegif($img);
imagedestroy($img);
}