how to do in-memory transformations ?

Fredrik Lundh fredrik at
Mon Dec 18 11:05:30 CET 2000

Andreas Jung:

> Due to the poor PIL documentation I have not found a suitable
> solution yet. Any ideas ?

how about being a little more polite?

if you cannot figure out how to open, load, and resize an image
from the documentation, I doubt you've read it at all.

(hint: to open, load, and resize, use the methods "open", "load", and
"resize".  load is optional.  to figure out the format, use the attribute
named "format").

to figure out how to save an image to a string (instead of a temporary
file), you might have to read the documentation a little bit more care-

here's the relevant part:

    "save(outfile, options), save(outfile, format, options).

    Saves the image under the given filename


    You can use a file object instead of a filename. In this case, you
    must always specify the format. The file object must implement
    the seek, tell, and write methods, and be opened in binary mode."

if you don't know how to create an in-memory file object, look
up StringIO in the Python library reference.


More information about the Python-list mailing list