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);
?>