如何关闭在枕头中打开的图像? [英] How do I close an image opened in Pillow?
本文介绍了如何关闭在枕头中打开的图像?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个导入了Pillow库的python文件.我可以用
I have a python file with the Pillow library imported. I can open an image with
Image.open(test.png)
但是我如何关闭该图像?我不是在使用Pillow编辑图像,只是为了显示图像并允许用户选择保存或删除图像.
But how do I close that image? I'm not using Pillow to edit the image, just to show the image and allow the user to choose to save it or delete it.
推荐答案
You can also do it in a with block:
with Image.open('test.png') as test_image:
do_things(test_image)
使用Image.close()
的示例:
test = Image.open('test.png')
test.close()
这篇关于如何关闭在枕头中打开的图像?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文