What are some common pitfalls when using PHP to display images in a new window?

One common pitfall when using PHP to display images in a new window is not setting the correct content type header before outputting the image data. To solve this issue, you need to set the content type header to "image/jpeg" or "image/png" depending on the image type before outputting the image data.

<?php
// Get image data
$imageData = file_get_contents('path/to/image.jpg');

// Set content type header
header('Content-Type: image/jpeg');

// Output image data
echo $imageData;
?>