I believe what Schneck meant is:
header('Content-Type: '.$mime_type);
$fp = fopen('php://stdout', 'w+');
$image->writeImageFile($fp);
fclose($fp);
This may cause problems, especially in multipage files, so you should probably use:
ob_start();
$fp = fopen('php://output', 'w+');
$image->writeimagefile($fp); // or writeImagesFile for multipage PDF
fclose($fp);
$out = ob_get_clean();
header('Content-Length: '.strlen($out));
echo $out;
This is tested and working.
I realize this is an old question. The reason I'm posting this is that if you want to write a multipage PDF, this is the solution, as Nabab's solution only works for single images.
You can also use (PHP 5.1.0+):
$fp = fopen('php://temp', 'r+');
$image->writeimagesfile($fp);
rewind($fp);
$out = stream_get_contents($fp);
header('Content-Length: '.strlen($out));
fclose($fp);
echo $out;
This way seems to be faster if your PHP version supports it.
Before you downvote, the reason I added this as an answer and not a comment is I don't have sufficient reputation to comment. Hope that is alright. Just wanted to get this out there in case anyone needed it.