Python-list Digest, Vol 64, Issue 617
ferdinandsousa at gmail.com
Wed Jan 28 09:40:13 CET 2009
> Secondly, it has no way to display the image drawn on. Is it possible, or
>>> I have to pass the image off to another module's methods?
>> im.show() this will display the image (and any modification(s) made to
>> Example: Draw a Grey Cross Over an Image
>> import Image, ImageDraw
>> im = Image.open("lena.pgm")
>> draw = ImageDraw.Draw(im)
>> draw.line((0, 0) + im.size, fill=128)
>> draw.line((0, im.size, im.size, 0), fill=128)
>> del draw
>> # write to stdout
>> im.save(sys.stdout, "PNG")
>> Hope that helps
> That's pretty much the code I used. In fact, I borrowed it from the pdf. I
> just tried it, and it output "%PNG".
im.save("picture1" "png") # not sure if it has to be "PNG"
What was happening earlier was that the binary data was being directed to
the standard output, which is where all your text is printed by a print
statement (print func in Py 3000). If you open a png in notepad, you will
notice that the 1st four characters are indeed %PNG, which is the magic
number for a PNG file.
For further info, see:
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Python-list