[H-GEN] Embedding images in HTTP response?

Michael Anthon michael at anthon.net
Thu Feb 15 09:58:51 EST 2001


[ Humbug *General* list - semi-serious discussions about Humbug and  ]
[ Unix-related topics.  Please observe the list's charter.           ]
[ Worthwhile understanding: http://www.humbug.org.au/netiquette.html ]

Greetings,
I'm trying to figure out if it's possible to embed an image into an HTTP
response with some HTML.  

The reason I want to do this..

I'm tossing around the idea of dynamically generating graphs using the
GD funcitons in PHP.  This all works quite nicely *but* there is at
least 3 ways that I can think of for doing it, each with it's own set of
problems.

1. 
Probably the simplest in terms of coding is to embed a src tag for the
image into the HTML that simply calls a script to generate the image and
the script returns the image with appropriate headers.  This is easy and
I can do this already.  
Downsides of this method include 
 - passing parameters back from the browser to get the right data on the
graph
 - a separate query on the database.  In some situation I will be
displaying a graph as well as a table of the same data and the query can
be a long running one.  Having to run the query twice really is out of
the question.

2.
A bit more complicated... write the image to a temp file and embed the
URL of the file in the HTML.  This removes the double query problem at
the expense of a bit more code in the 'garbage collection' area to clean
up old image files.

3.
Multipart response with embedded image.  I'n not 100% certain this is
possible (hence this email).  I have figured out how to send a multipart
reponse, but cannot determine how to specify in the src attribute for
the image tag.  This method would work really well since it overcomes
all limitations (that I can think of) for the previous methods.

So... is what I am wanting to do possible, and if so, how?

Cheers
Michael Anthon

--
* This is list (humbug) general handled by majordomo at lists.humbug.org.au .
* Postings to this list are only accepted from subscribed addresses of
* lists 'general' or 'general-post'.



More information about the General mailing list