Since you are on Windows, you need to provide the "rb" mode to open, or
it will convert newline characters in your file, which can trash your
binary data. Also, I don't understand what b2a_uu does, but the docs
say its input string should be at most 45 characters, so it doesn't seem
like what you want.
When you say "convert it to an equivalent ascii string", what do you mean?
--Ned.
http://nedbatchelder.com
Ashish Sethi wrote:
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
_______________________________________________
Image-SIG maillist - Image-SIG@python.org
http://mail.python.org/mailman/listinfo/image-sig
--
Ned Batchelder, http://nedbatchelder.com
_______________________________________________
Image-SIG maillist - Image-SIG@python.org
http://mail.python.org/mailman/listinfo/image-sig