returning a picture from PIL

Peter Posselt Vestergaard posselt at brics.dk
Tue Mar 12 10:57:41 EST 2002


Hi
I would like to show a image on a webpage by calling a python script that
through the Python Imaging Library (PIL) loads a picture and then returns
it.
I'm trying to do it like this:
In the webpage I write:
[...]
<img src="http://www.myserver/myscript.py" height="400" width"=500>
[...]

and in myscript.py I write:

[...]
pic = Image.open(urllib.urlretrieve(url)[0])
print "Content-type: image/png\n\n"
pic.save(sys.stdout,"PNG")

the page takes some time loading the picture but nothing is ever shown. If I
change sys.stdout to "filename" the picture is stored perfectly on my disk.
Anyone who can tell me how to do this kind of output from PIL?
Thanks
Regards
Peter Vestergaard






More information about the Python-list mailing list