<?php
$ip = $_SERVER['REMOTE_ADDR']; #get the users IP address
$font = 'arial'; #load the font file (make sure arial.ttf is in the same directory)
$size = imagettfbbox(10,0,$font,$ip); #get the height and width of the IP address
$width = $size[2] + $size[0] + 3;
$height = abs($size[1]) + abs($size[7]);
$im = imagecreate($width, $height); #create an image the same height/width of the text
$bg = imagecolorallocate($im, 255, 255, 255); #image background color
$color = imagecolorallocate($im, 0, 0, 0); #color used for the text
imagettftext($im, 10, 0, 0, 10, $color, $font, $ip); #write the IP address to the image
header('Content-type: image/jpeg');
imagejpeg($im);
imagedestroy($im);
?>