Newbie has question that's not exactly Python...

Kragen Sitaker kragen at dnaco.net
Mon Apr 2 18:45:22 EDT 2001


In article <Vk6y6.15579$iU.3117864 at news1.rdc1.md.home.com>,
Gary Walker <borealis3 at home.com> wrote:
>When a web app needs to produce an image, it's usually a trivial task:
>simply reference the image in the HTML code, and voila.
>
>How does one go about producing a dynamically generated image? That is to
>say, one that didn't exist until the python script ran? I hope I don't have
>to save it to some tempfile, and reference *that* in my python code.

Dynamically generated images can be included in all kinds of documents,
including documents not produced by your Python script.

Saving to a tempfile would work.

>Thinking aloud here:
>Ideally, one would reference a SCRIPT instead of an image, and the script
>would return the image to the, the... page??

Do you mean <script>?  That won't work well --- it's hard to generate
images from JavaScript.  (Although my officemate did it by generating a
16x16 frameset and changing the background colors of the frames.)

Anyway, if you can specify the inputs to the image generation, you can
say something like <img src="img.cgi?data=1+3+4+17" /> and generate the
image from a CGI script.  Just 
print "Content-Type: image/png\r\n\r\n" + pngdata;

It's sort of a hassle that you can't do this from the initial script.
-- 
<kragen at pobox.com>       Kragen Sitaker     <http://www.pobox.com/~kragen/>
Perilous to all of us are the devices of an art deeper than we possess
ourselves.
       -- Gandalf the White [J.R.R. Tolkien, "The Two Towers", Bk 3, Ch. XI]




More information about the Python-list mailing list