1<?php 2header("Content-type: image/png"); 3header("Expires: Mon, 01 Jul 2003 00:00:00 GMT"); 4header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); 5header("Cache-Control: no-cache, must-revalidate"); 6header("Pragma: no-cache"); 7 8/*image generation code*/ 9if(isset($_GET['text'])) { 10 $width = strlen($_GET['text']) * 11; 11} else { 12 $width = 66; 13} 14$bg = imagecreatetruecolor($width, 15); 15 16//This will make it transparent 17imagesavealpha($bg, true); 18$trans_colour = imagecolorallocatealpha($bg, 0, 0, 0, 127); 19imagefill($bg, 0, 0, $trans_colour); 20 21//Text to be written 22$text = isset($_GET['text']) ? $_GET['text'] : "No Name"; 23 24// Black Text 25$black = imagecolorallocate($bg, 0,0,0); 26 27$font = './DejaVuSans.ttf'; //path to font you want to use 28$fontsize = 10; //size of font 29 30//Writes text to the image using fonts using FreeType 2 31imagettftext($bg, $fontsize, 0, 10, 12, $black, $font, $text); 32 33//Create image 34imagepng($bg); 35 36//destroy image 37ImageDestroy($bg); 38