how to do in-memory transformations ?

Fredrik Lundh fredrik at effbot.org
Mon Dec 18 05:05:30 EST 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-
fully:

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.

</F>





More information about the Python-list mailing list