This is a script i made once. I hope it helps you
[php]<?php
// Set size
$sizex = '200';
$sizey = '30';
// Set positions
$posx = '10';
$posy = '29';
$text = $_SERVER['REMOTE_ADDR'];
$fonts_path = './fonts/'
// Replace path by your own font path
//$font = $counter_root . 'fonts/TRASHED.ttf';
$font = $fonts_path . 'UnrealT.ttf';
// Output
// Set the content-type
header('Content-type: image/png');
// Create the image
$im = imagecreatetruecolor($sizex, $sizey);
// Decrement sizes
$sizex--;
$sizey--;
// Create some colors
$white = imagecolorallocate($im, 255, 255, 255);
$grey = imagecolorallocate($im, 128, 128, 128);
$black = imagecolorallocate($im, 0, 0, 0);
imagefilledrectangle($im, 0, 0, $sizex, $sizey, $white);
// Add some shadow to the text
//imagettftext($im, 20, 0, $posx+1, $posy+1, $grey, $font, $text);
// Add the text
imagettftext($im, 20, 0, $posx, $posy, $black, $font, $text);
// Using imagepng() results in clearer text compared with imagejpeg()
imagepng($im);
imagedestroy($im);
?>[/php]