如何在PHP中一次在多个图像中绘制填充矩形?

I need to draw color filled rectangles in multiple images at the same time.

$path      = "D:\Images\sample.png";      
$result_path  = "D:\Images\output\sample_output.png";
$image        = imagecreatetruecolor(500, 700);
$image        = imagecreatefrompng($path);
$color        = imagecolorallocatealpha($image, 181, 255, 1, 75);
imagefilledrectangle($image, 15, 15, 30, 30, $color);
header('Content-Type: image/png');
imagepng($image, $result_path);
imagedestroy($image);

This code helped to draw a filled rectangle in a single image.

Is it possible to draw filled rectangles on multiple images at the given co-ordinates of x and y?

To draw multiple images in PHP from different requests at the same time you can't save the image to a static filename. $result_path should be NULL or your call to imagepng shouldn't include a second argument. It can be reduced to imagepng($image). The code you have posted will output the png to a file but it won't display the image.