<?php
//創建畫布
$width = 500;
$height = 800;
$image=imagecreatetruecolor($width,$height);
//var_dump($image);
//處理畫布
//imagecolorallocate() 分配顏色到畫布上,選擇一個顏色。
//分配顏色
$green=imagecolorallocate($image,0,255,0);
//填充(油漆桶):imagefill(畫布,填充點X坐標,填充點Y坐標,顏色);
imagefill($image,0,0,$green);
//輸出:
imagepng($image,'./green.png');
//直接輸出到浏覽器
imagepng($image);
//告知浏覽器,輸出的內容為png格式的圖片
header("content-type:image/png");
//關閉畫布
imagedestroy($image);
?>