比如代码:
<?php
header('Content-Type: image/png');
$im = imagecreatetruecolor(500, 500);
$white = imagecolorallocate($im, 0xff, 0xff, 0xff); // #FFFFFF
imagefill($im, 0, 0, $white); // 设置背景颜色
$blue = imagecolorallocate($im, 0x00, 0x00, 0xff); // #0000FF
imageline($im, 40, 20, 390, 450, $blue);
imageline($im, 420, 20, 380, 450, $blue);
imageline($im, 28, 35, 460, 28, $blue);
$green = imagecolorallocate($im, 0xb5, 0xe6, 0x1d); // #B5E61D
imagefill($im, 300, 200, $green);
imagesetpixel($im, 300, 200, $blue);
imagepng($im);
imagedestroy($im);
?>
输出的图像为: