<?php
Header("Content-type: image/gif");
// $s is the font size in pixels
if(!
isset($_GET['s'])) {$s =
32;
} else {$s =
$_GET['s'];
} // $text is the text to display
if(!
isset($_GET['text'])) {$text =
"PHP is cool!";
} else {$text =
$_GET['text'];
} // $f_path is the path to your font file
$f_path = "c:/windows/fonts/times.ttf";
$size = imagettfbbox($s,0,$f_path,$text);
$dx =
abs($size[2]-
$size[0]);
$dy =
abs($size[5]-
$size[3]);
$xpad=9;
$ypad=9;
$im = imagecreate($dx+$xpad,$dy+$ypad);
$blue = ImageColorAllocate($im, 0x2c,0x6D,0xAF);
$black = ImageColorAllocate($im, 0,0,0);
$white = ImageColorAllocate($im, 255,255,255);
ImageRectangle($im,0,0,$dx+$xpad-1,$dy+$ypad-1,$black);
ImageRectangle($im,0,0,$dx+$xpad,$dy+$ypad,$white);
ImageTTFText($im, $s, 0, (int)($xpad/2)+1, $dy+(int)($ypad/2), $black, "$f_path", $text);
ImageTTFText($im, $s, 0, (int)($xpad/2), $dy+(int)($ypad/2)-1, $white, "$f_path", $text);
ImageGif($im);
ImageDestroy($im);
?>