[Image-SIG] Using PIL to display resized images over the web
Chris Cogdon
chris at cogdon.org
Wed Oct 8 19:06:23 EDT 2003
On Wednesday, Oct 8, 2003, at 15:49 US/Pacific, Steven M. Castellotti
wrote:
> Hey all--
>
> I have a simple photo website written in python. I would like to be
> able to use Python Imaging Library to read an image file from the disk,
> resize/thumbnail it in memory, and then print the modified image
> (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 'save' method can take a string or a file object. If you pass a
string it will 'open' that file and write the image to it. If you pass
a file object, it will simply write to that file object.
So... if you want to save it into a string for later processing, create
a StringIO object and pass it to the save method.
--
("`-/")_.-'"``-._ Chris Cogdon <chris at cogdon.org>
. . `; -._ )-;-,_`)
(v_,)' _ )`-.\ ``-'
_.- _..-_/ / ((.'
((,.-' ((,/ fL
More information about the Image-SIG
mailing list