You will have to work with adjusting headers and stuff. PhP outputs data as an text/html stream. you'll need to set the headers to image, and transferr the image file into an image stream, e.g.
header("Content-type: image/$format");
$fh = @fopen($filename, "rb")) {
fpassthru($fh);
Unless you only want to show an image on your page, in which case you will need to use a valid HTML code to display an image:
<img src="TheImage.jpg">