[Image-SIG] Converting a binary file to ascii

Ashish Sethi ashishbitsgoa at gmail.com
Wed Sep 3 11:10:03 CEST 2008


I have PPM-P6 image file which is in binary format .The file is of the type  :-

P6
128 128
255
ߢ…ä£{ä¡~ߟxÞ¡yàšfß›lÜšyâ›jåŸhæ¦ué­yê§vé¡pÛš»ubž^Y¦f](c)g ..........and so on.

How can i read the 4th line (binary) and convert it to an equivalent
ascii string. I used the following method but couldn't get the desired
result..

import binascii
from binascii import b2a_uu
infile=open("C:\\Documents and Settings\\Desktop\\lena.ppm")
a=infile.readline()
b=infile.readline()
c=infile.readline()
d=infile.readline()
z=b2a_uu(d)
print z

This script gave me some random absurd data as output.
Plz help


More information about the Image-SIG mailing list