Hello everyone!
I am trying to get the rgb values of each pixel from a png image i took with the phone camera. The code i am using is:
f= open("E:\\Images\\minic1.png", "rb")
f.seek(8+8+13+4)
chunk = []
while 1:
n = struct.unpack(">L", f.read(4))[0]
if n==0: break #'IEND' chunk
f.read(4)
chunk.append(f.read(n))
f.read(4)
f.close()
data = zlib.decompress("".join(chunk))
unfortunately, this leaves me with the array 'data', whose elements are meant to be hex number values but come out in the form '\x00', which confuses python and it won't let me manipulate it as a string/convert it to a decimal number. It can compare this type of number to each other correctly( i.e. it could correctly deduce that, for example, 'x\00'>'\xff'), but that's about it. I tried changing the '\' with a '0' but it won't let me. How do i overcome this?
Thank you in advance,
N

Reply With Quote


