[Image-SIG] create image-instances from data strings
Fredrik Lundh
fredrik@pythonware.com
Wed, 18 Oct 2000 14:49:25 +0200
Torsten wrote:
> Cool, that works but only for the open method. Image.save(file) and getting
> values with file.getvalue() gives me the initial data of der StringIO
> object.
what initial data? (a new StringIO object has no content).
here's an example cut and pasted from a terminal window
(using Python 1.5.2, PIL 1.1):
>>> import Image
>>> im = Image.open("/images/lenna.im")
>>> import StringIO
>>> file = StringIO.StringIO()
>>> im.save(file, "JPEG")
>>> data = file.getvalue()
>>> len(data)
29921
>>> repr(data[:10])
"'\\377\\330\\377\\340\\000\\020JFIF'"
</F>