Debes de realizarlo asi:
ya que no le puedes enviar al browser nada antes de generar la imagen y me refiero a lo siguiente :
para eso ya estas utilizando la funcion header(), lo que me parese raro es que no hayas indicado el error que genera el header:
PHP:
<?php
$im = @ ImageCreate ( 150, 100) or die ( "Cannot create a new GD image.");
$background_color = ImageColorAllocate ($im, 255, 255, 255);
$text_color = ImageColorAllocate ($im, 233, 14, 91);
ImageString ($im, 1, 5, 5, "A Simple Text String", $text_color );
header ("Content-type: image/png");
imagepng($im);
imagedestroy($im);
?>
PHP:
<html>
<head>
<title>documento sin título</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
Código:
Warning: Cannot modify header information - headers already sent by (output started at /var/www/htdocs/imagen.php:8)