I have been working on a script which uses ImageJPEG() to output a JPEG image which has been modified. The script works fine when used to save the new image to a file.
I can also generate the image on-the-fly and present it in the browser without saving it. The code for doing so looks like this:
header("Content-type: image/jpeg");
ImageJPEG($image_resized);
This works so long as no HTML text has been generated prior to call to header(). The header() call for the JPEG must be the first in the document sent to the browser. Obviously, that's not very practical as I would like to surround the image with explanatory text.
I tried using header() in this way, again calling it inside an HTML page:
header("Content-type: image/jpeg");
header("Content-Disposition: inline");
ImageJPEG($image_resized);
Again, this did not work.
Is there any way to send a dynamically generated image as an inline image in a document produced with PHP? Or must I save the image as a file and use the <img src> tag?