<?php
// 既存の画像より画像リソースを作成
$im = imagecreatefrompng("./sample03.png");
// 白色を作成
$white = imagecolorallocate($im, 0xFF, 0xFF, 0xFF);
// 黒色を作成
$black = imagecolorallocate($im, 0x55, 0x55, 0x55);
// 短形を描画する
imagefilledrectangle($im, 50, 50, 150, 150, $black);
// 画像出力
header("Content-type: image/png");
ImagePNG($im);
?>