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