imagecolorallocate (画像リソース, 左上X座標, 左上Y座標
右下X座標, 右下Y座標, 色番号);
header("content-type: image/png");
$image = imagecreate(120,120);
$black = imagecolorallocate($image,0,0,128);
$yellow = imagecolorallocate($image,255,255,0);
imagefilledrectangle($image,20, 20, 100, 100, $yellow);
imagepng($image);
imagedestroy($image);
imagerectangle()関数を参照してください。関連関数