<br>
<div>Hi all,</div>
<div>I have a problem in converting the pixel data (read from a string and written to a file using fromstring command in PIL ).</div>
<div>The file handle of this file is called buffer. Now, when I tried to open the file as an image file but it didnt work.</div>
<div>Then I read the documentation of PIL and found this written about fromstring function</div>
<div>&quot;<font face="TrebuchetMS" size="3">Note that this function decodes pixel data, not entire images. If you</font></div>
<div><font face="TrebuchetMS" size="3">have an entire image in a string, wrap it in a </font><b><font face="TrebuchetMS-Bold" size="3">StringIO </font></b><font face="TrebuchetMS" size="3">object, and use</font></div>
<div><b><font face="TrebuchetMS-Bold" size="3">open </font></b><font face="TrebuchetMS" size="3">to load it.&quot;</font></div>
<div><font face="TrebuchetMS" size="3">so i wrote the following code....</font></div>
<div>&nbsp;</div>
<div>file = StringIO.StringIO(buffer)<br>img = Image.open(file)<br>img.save(file, &#39;JPEG&#39;)</div>
<div><br><strong>Error:</strong></div>
<div>img = Image.open(file)<br>&nbsp; File &quot;/home/rahhal/python/lib/python2.4/site-packages/PIL/Image.py&quot;, line<br>1745, in open<br>&nbsp;&nbsp;&nbsp; raise IOError(&quot;cannot identify image file&quot;)<br>IOError: cannot identify image file<br>
&nbsp;</div>
<div>Can any one please help in solving my problem??</div>
<div>&nbsp;</div>
<div>&nbsp;</div>