How can the code snippet provided be optimized or improved to ensure proper rendering of the filled rectangle on both Windows and Linux servers?

The issue with the current code snippet is that it relies on the GD library for rendering the filled rectangle, which may not be available or behave differently on Windows and Linux servers. To ensure proper rendering on both platforms, it is recommended to use the PHP built-in functions for drawing shapes, such as `imagefilledrectangle()`, which are platform-independent.

<?php
// Create a blank image
$image = imagecreatetruecolor(400, 300);

// Set the background color
$bg_color = imagecolorallocate($image, 255, 255, 255);
imagefill($image, 0, 0, $bg_color);

// Set the rectangle color
$rect_color = imagecolorallocate($image, 255, 0, 0);

// Draw a filled rectangle
imagefilledrectangle($image, 50, 50, 350, 250, $rect_color);

// Output the image
header('Content-Type: image/png');
imagepng($image);

// Free up memory
imagedestroy($image);
?>