[Image-SIG] PNG Pixels to Hex/Binary

Karsten Hiddemann karsten.hiddemann at mathematik.uni-dortmund.de
Tue May 27 01:50:54 CEST 2008


Rodrigo schrieb:
> I ended up editing it to this... however I have the hex code showing in
> text, Basically it should be a binary file in the end, not a text file -
> apologies for the confusion.  Perhaps the original that you wrote Karsten
> did that, however it was outputting to the screen and not a file.

No, that's exactly what I intended it to do since you wrote something 
about text files and HTML color codes. Seems what you really want is:

from PIL import Image

if __name__=="__main__":
	im = Image.open("image.png")
	out = file('image.raw', 'w')
	out.write(im.tostring())


More information about the Image-SIG mailing list