How can one prevent memory leaks when working with image resources in PHP, especially in a multi-user environment?

Memory leaks can occur when working with image resources in PHP, especially in a multi-user environment, if the resources are not properly released after use. To prevent memory leaks, it is important to explicitly free up memory allocated for image resources using the `imagedestroy()` function after they are no longer needed.

// Open and manipulate image resource
$image = imagecreatefromjpeg('example.jpg');
// Use the image resource
// Free up memory allocated for the image resource
imagedestroy($image);