[Image-SIG] Re: tostring

Fredrik Lundh fredrik at pythonware.com
Sat Apr 17 10:52:04 EDT 2004


Kai Hendry wrote:

> I can't work out tostring. Could someone fix this or provide me an
> example?

tostring copies the pixels in the image to a Python string buffer (the
opposite of fromstring).

if you want to save an image to stdout, just save it to stdout:

    im.save(sys.stdout)

if you want to save an image to a string, use the StringIO module:

    import StringIO
    ...
    out = StringIO.StringIO()
    im.save(out)
    data = out.getvalue()

</F>






More information about the Image-SIG mailing list