<?php
// Set the vertices of polygon
$values = array(
150, 50, // Point 1 (x, y)
55, 119, // Point 2 (x, y)
91, 231, // Point 3 (x, y)
209, 231, // Point 4 (x, y)
245, 119 // Point 5 (x, y)
);
// It create the size of image or blank image.
$image = imagecreatetruecolor(300, 300);
// Set image background color
$bg = imagecolorallocate($image, 255, 255, 255);
// Set image color
$blue = imagecolorallocate($image, 0, 153, 0);
// fill the background
imagefilledrectangle($image, 0, 0, 300, 300, $bg);
// Draw the polygon
imagefilledpolygon($image, $values, 5, $blue);
// Output of the image.
header('Content-type: image/png');
imagepng($image);
imagedestroy($image);
?>