Search code examples
pythonpython-imaging-libraryaggdraw

Python PIL: Modifying images using PIL, Flush() doesn't work


from PIL import Image
import webbrowser, aggdraw

im = Image.open('Background.png')
# Drawing cross on top of PIL image
d = aggdraw.Draw(im)
p = aggdraw.Pen("black", 0.5)
d.line((0, 0, 500, 500), p)
d.line((0, 500, 500, 0), p)
d.flush()
webbrowser.open('Background.png')

The above is the code I'm running. I use web-browser to open the image because the PIL show() doesn't seem to function. The above returns Background.png to me unchanged.

Any input at all would be appreciated.


Solution

  • flush doesn't write back out to a file - it simply assures that all internal operations are completed. You need to use the im.save function to write the results back to a file.