简体   繁体   English

Python PIL:使用PIL修改图像,Flush()不起作用

[英]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. 我使用网络浏览器打开图像,因为PIL show()似乎不起作用。 The above returns Background.png to me unchanged. 以上返回Background.png给我不变。

Any input at all would be appreciated. 任何输入都将不胜感激。

flush doesn't write back out to a file - it simply assures that all internal operations are completed. flush不会写回文件-它只是确保所有内部操作都已完成。 You need to use the im.save function to write the results back to a file. 您需要使用im.save函数将结果写回到文件中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM