[Tutor] From byte[] to Image

2006-09-16 Thread Ziad Rahhal
Hi, I convert an Image to bye array in Java (web-services) and send it to a python client. At the client side (python code) i receive the bytes, and then i need to transform them into the image again. Here is what I am doing: #** # fil

Re: [Tutor] From byte[] to Image

2006-09-16 Thread Alan Gauld
Hi Ziad, Can you give us a bit mor4e detail. > #** > # fileName is the path of the file > stream = service.getFile(fileName) > > file = open("pic.jpeg", 'w') > > img = Image.frombuffer("1", (128, 128), stream) > img.save(file) Which l

Re: [Tutor] From byte[] to Image

2006-09-17 Thread Ziad Rahhal
Hi Alan, The Library I am using is the PIL. And I read the Docs, they say the following about "frombuffer" operation: (Note that this function decodes pixel data only, not entire images. If you have an entire image file in a string, wrap it in a StringIO object, and use open to load it.) So I gu

Re: [Tutor] From byte[] to Image

2006-09-17 Thread Alan Gauld
> (Note that this function decodes pixel data only, not entire images. > If you > have an entire image file in a string, wrap it in a *StringIO* > object, and > use > *open*to > load it.) > > So I guess "frombuffer" must not be used in my case. Looks like it, but did you try what it suggested,

Re: [Tutor] From byte[] to Image

2006-09-18 Thread Ziad Rahhal
I do the following: file = StringIO.StringIO(buffer) img = Image.open(file) img.save(file, 'JPEG') I get this error: img = Image.open(file)   File "/home/rahhal/python/lib/python2.4/site-packages/PIL/Image.py", line 1745, in open     raise IOError("cannot identify image file") IOError: cannot id

Re: [Tutor] From byte[] to Image

2006-09-18 Thread Ziad Rahhal
I do the following: file = StringIO.StringIO(buffer) img = Image.open(file) img.save(file, 'JPEG') I get this error: img = Image.open(file)   File "/home/rahhal/python/lib/python2.4/site-packages/PIL/Image.py", line 1745, in open     raise IOError("cannot identify image file") IOError: