<?php

// original png image to put text on
$orig_image "orig.png";


// get the uptime and load from a linux server
$uptime exec("/usr/bin/uptime");
preg_match("|up\s+(.+),\s+\d+\suser.+load average: ([^,]+), ([^,]+), ([^,]+)|i"$uptime$matches);

$label_uptime "$matches[1]";
$label_load "$matches[2], $matches[3], $matches[4]";


// create the $img resource id from existing image
$im = @ImageCreateFromPNG($orig_image);


// color to make text (red, blue, green)
$color ImageColorAllocate($im000);


// print uptime
// format: imagestring(resource, int font(1-5), int x offset, int y offest, string s, int color)
ImageString($im1623$label_uptime$color);


// print server load
// format: imagestring(resource, int font(1-5), int x offset, int y offest, string s, int color)
ImageString($im16215$label_load$color);


// now time to actually print the image
Header("Content-Type: image/png");
ImagePNG($im);


// clear the resource from memory
ImageDestroy($im);

?>