Python-list Digest, Vol 64, Issue 617

Ferdinand Sousa ferdinandsousa at
Wed Jan 28 09:40:13 CET 2009

> Secondly, it has no way to display the image drawn on. Is it possible, or
>>> do
>>> I have to pass the image off to another module's methods?
>> this will display the image (and any modification(s) made to

>> Example: Draw a Grey Cross Over an Image
>> import Image, ImageDraw
>> im ="lena.pgm")
>> draw = ImageDraw.Draw(im)
>> draw.line((0, 0) + im.size, fill=128)
>> draw.line((0, im.size[1], im.size[0], 0), fill=128)
>> del draw
>> # write to 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".
OR"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...
URL: <>

More information about the Python-list mailing list