Questa settimana l'ho scritto almeno 25 volte.
la funzione header(), ma anche setcookie, start_session, ...
Va inviata prima di qualsiasi output verso il client.
In questo caso, anche l'header html è un output verso il client.
Prova a scrivere solo il codice php e vedrai che funzionerà benissimo.
oppure anche così dovrebbe
<?php
header("Content-type: image/png");
?>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>
<body>
<?php
$im = @imagecreate(110, 20)
or die("Cannot Initialize new GD image stream");
$background_color = imagecolorallocate($im, 0, 0, 0);
$text_color = imagecolorallocate($im, 233, 14, 91);
imagestring($im, 1, 5, 5, "A Simple Text String", $text_color);
imagepng($im);
imagedestroy($im);
?>
</body>
</html>