Using PIL(/other?) to display resized images over the web?
matt at pollenation.net
Thu Oct 9 01:50:54 CEST 2003
Steve Castellotti wrote:
> I have a simple photo website written in python. I would
>like to be able to use Python Imaging Library (or similar) to read an
>image file from the disk, resize/thumbnail it in memory, and then print
>the modified image to stdout (sending it to the client web browser after
>the proper MIME headings).
> Currently, I have only managed to do this via
>Image.save() to a temporary file and then sending that, but of course that
>is somewhat inefficient. Surely there's an easier way to do this, perhaps
>via file descriptors?
The outfile argument to Image.save() can be a string (filename) or a
file object. You can send the image to the browser by saving the
thumbnail to sys.stdout instead of the temporary file name, i.e.
print 'Content-Type: image/gif'
Matt Goodall, Pollenation Internet Ltd
e: matt at pollenation.net
More information about the Python-list