Dynamic image creation for the web...

Tompa tompa1969 at yahoo.com
Sun Aug 28 16:09:10 EDT 2005


Richard Lewis <richardlewis <at> fastmail.co.uk> writes:
> It would be useful to know what web server software you're using. 

I intended to add that info but forgot...
I run IIS on W2K, python 2.4.1 and PIL 1.1.5.

> The other thing you may need to check is the HTTP header of the
> generated image. 
If possible I'd rather separate the HTTP/HTML-stuff from image creation.
I'd like to have an HTML file that refers to a py-file that creates images 
which are returned somehow (sys.stdout or something else in memory) and 
incorporated within the HTTP-response.

> It should be possible to create an HTTP response from
> your create_image.py script (as opposed to just an image) with a MIME
> type of image/jpeg and manually insert the binary image data in the
> response body...
Yes, I believe so too. Something like this, as suggested by Benjamin:
sys.stdout.write('Status: 200 OK\r\n')
sys.stdout.write('Content-type: image/gif\r\n')
sys.stdout.write('\r\n')
im.save(sys.stdout, "GIF")

But it does not work for some reason!? Besides, I was hoping for a solution 
which could skip the HTTP-header related stuff...

Regards,
/Tompa





More information about the Python-list mailing list