this is often used to retreive an image from a database (stored as a blob) - here is an example:
// querystring = page.php?id=21
mysql_connect("localhost","root","password");
mysql_select_db("prod");
// retrive binary image, and type
$query = "select bin_type, bin_data from $table where ref = '$id'";
$result = @MYSQL_QUERY($query);
$data = @MYSQL_RESULT($result,0,"bin_data");
$type = @MYSQL_RESULT($result,0,"bin_type");
$type = "";
// pass the image type and binary data to browser
Header("Content-type: $type");
// header("Content-Disposition: attachment; filename=$filename");
echo $data;
You need to have the binary data (image) and its type (application/jpeg or whatever) and pass these as headers to the browser.
In may be possible to do the same thing with an image file directly, you could give it a try.