Перед рисованием фигуры, добавьте DG Liabrary в файл php.in.Вот код:
<?php
// Create a 200 x 200 image
$canvas = imageCreateTrueColor(800, 800);
// Allocate colors
$pink = imageColorAllocate($canvas, 255, 105, 180);
$white = imageColorAllocate($canvas, 255, 255, 255);
$green = imageColorAllocate($canvas, 132, 135, 28);
imageLine($canvas, 40, 50, 130, 150, $white); //draw a line
imagerectangle($canvas, 150, 50, 250, 150, $pink); //draw a rectange
filled with color
imageFilledRectangle($canvas, 300, 50, 500, 150, $green);//draw a rectangle
imageellipse($canvas, 600, 100, 100, 100, $green); //draw a circle
$points = array ( 76, 228, // Point 1 (x, y)
105, 228, // Point 2 (x, y)
117, 197, // Point 3 (x, y)
129, 228, // Point 4 (x, y)
156, 228, // Point 5 (x, y)
135, 246, // Point 6 (x, y)
149, 285, // Point 7 (x, y)
117, 260, // Point 8 (x, y)
82, 288, // Point 9 (x, y)
98, 245 // Point 10 (x, y)
);
imagefilledpolygon( $canvas, $points, 10, $white );//draw a star with polygon()
// Output and free from memory
header('Content-Type: image/png');
imagepng($canvas);
imagedestroy($canvas);
?>