Louis93
Louis93

Reputation: 3923

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.

Upvotes: 0

Views: 1221

Answers (1)

Mark Ransom
Mark Ransom

Reputation: 308452

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.

Upvotes: 6

Related Questions