header ("Content-type: image/png");
headers are sent to make sure the broswer knows it's a picture, and not text.
$im = @ImageCreateFromPNG ("php.png");
if(!$im) {
all that line does is check that an image can be created, if you can create an image space then nothing else happens.
$len = 8*(strlen($ip))+6;
$hig = 16;
those lines check the length of the IP address, so a different sized address will generate different numbers, (eg 4.0.0.1 or 217.195.167.105) so a larger box is drawn for a longer text string...
$img_handle = ImageCreate ($len, $hig) or die ("Cannot Create image");
that line actually creates the image where $len is the horizontal length of the image and $hig is the height, so you can change these to be however you want them to to create large or small images.
$back_color = ImageColorAllocate ($img_handle, 0, 0, 0);
The first colour set is the back colour for the image
$txt_color = ImageColorAllocate ($img_handle, 255, 255, 255);
and that sets the forecolour, note that you cab define and use any number of colours that you want.
ImageString ($img_handle, 3, 5, 1, "$ip", $txt_color);
Image string function draws text on a picture
ImagePng ($img_handle); }
and that actually forms the picture from al the information that been stored in the memory space $inmg_handle
?>
You coluld draw on an image by getting rid of the second rceateimage line and just using the first image pointer ($im) which I'd only used as a test...
to be honest you'll find far more help on the PHP site than I can feasibly give you here, just use the function search to look up some of the functions, and you could look at the related functions as well.