//DEFINE CONTENT TYPE
Header("Content-type: image/jpeg");
//DEFINE BACKGROUND SIZE
$height = 300;
$width = 300;
//TELLS IT TO CREATE BACK (IMAGE) AT DEFINED SIZE
$im = ImageCreate($width, $height);
//TELLS IT WHAT COLOR TO MAKE YOUR BACK (IMAGE)
$bck = ImageColorAllocate($im, 255,255,255);
// MAKE YOUR BACKGROUND SHAPE.
imagefilledrectangle($im, 0, 0, 300, 300, $white);

$black =imagecolorallocate($im, 0, 0, 0);
$white = ImageColorAllocate($im, 255, 255, 255);
//GRID
$wd = 300;
$ht = 300;
//CHANGES SIZE OF SQUARES
$pixel = 10;

$grid_color = imagecolorallocate($im, 255, 255, 255);
for ($x = 0; $x < $wd; $x = $x + $pixel)
imageline($im, $x, 0, $x, $ht, $black);
for ($y = 0; $y < $ht; $y = $y + $pixel)
imageline($im, 0, $y, $wd, $y, $black);
imagesetthickness($im, 4);
imageline($im, 100, 0, 100, 300, $black);
imageline($im, 200, 0, 200, 300, $black);
imagesetthickness($im, 3);
imageline($im, 0, 100, 300, 100, $black);
imageline($im, 0, 200, 300, 200, $black);
/*Be sure you have allocated the colors in the grid or change them to colors you have allocated. You can change the height and width and pixel size of the squares for locating coordinates better...Thanks Dave*/
Imagejpeg($im);
//FREE THE IMAGE (CLEAR FROM CACHE)
imagedestroy($im);
?>