I'm trying to display an image on an HTML page using a PHP script in the image/src tag, but the image is broken. When I hard-code the output of getimage.php into the HTML it shows up just fine so I know the base64 encoding is correct. The page that shows the image needs to be HTML.
PHP:
<?php
header("Content-type: image/png");
$data = file_get_contents('arbitrary.png');
$base64 = 'data:image/png;base64,'.base64_encode($data);
echo $base64;
?>
HTML:
<html> <body> <img src="getimage.php" /> </body> </html>
Any ideas? Thanks in advance!