how to return a StringIO of an Image

JCM joshway_without_spam at myway.com
Fri Nov 14 15:38:43 EST 2003


Bengt Richter <bokr at oz.net> wrote:
> On Fri, 14 Nov 2003 16:45:39 +0100, "Fredrik Lundh" <fredrik at pythonware.com> wrote:

>>"Christoph" wrote:
>>
>>>    image.save('test', 'JPEG')
>>>    image=StringIO(image.????()) # what's the right method?
>>>    return image
>>>
>>> Any hints? Thanx!
>>
>>    file = StringIO()
>>    image.save(file, "JPEG")
>>    return file.getvalue()
>>
> You are recommending shadowing 'file' ?!

Why not?  Python is a block-structured language.  New builtins can
arrive in any release.




More information about the Python-list mailing list