[Image-SIG] tostring
Dmitry Vasiliev
lists at hlabs.spb.ru
Thu Feb 24 11:33:35 CET 2005
THOGROM.terra.es wrote:
> Hello list!
> I'm using python to store some images as strings.
> image = PIL.Image.open(sname)
> self.__simagestr = image.tostring()
> os.remove(sname)
tostring() just returns pixels data. If you want opening the string through
StringIO later you just can do:
self.__simagestr = open(sname).read()
> Later, I have to store this string on a file:
> def savedraw(self, suri):
> #suri is a path like "/home/image.jpeg"
> data = StringIO.StringIO(self.__simagestr)
> im = PIL.Image.open(data)
> im.save(data,'JPEG')
im.save(suri, 'JPEG') ?
> But the system shows the next error when execute PIL.Image.open(data)
> raise IOError("cannot identify image file")
--
Dmitry Vasiliev (dima at hlabs.spb.ru)
http://hlabs.spb.ru
More information about the Image-SIG
mailing list