关闭 Pillow 在 Window 照片查看器中打开的图像
Closing an image opened by Pillow in Window Photo Viewer
我试图在每次迭代中关闭通过迭代打开的每个图像。
我在下面提到了这个线程,但正确的答案没有产生结果。
我的代码
for i in Final_Bioteck[:5]:
with Image.open('{}_screenshot.png'.format(i)) as test_image:
test_image.show()
time.sleep(2)
我也试过了,
test_image.close()
,但没有结果。
我上面的循环打开了 5 个 Windows 照片查看器对话框;我希望通过迭代,每个 window 都会被关闭。
我也看到了这个帖子,但是答案已经过时了,所以不确定是否有更简单的方法来执行我想要的。
How can I close an image shown to the user with the Python Imaging Library?
谢谢=)
可以使用,但我在 Windows 上安装了不同的图像查看器,因为我找不到默认查看器的 .exe。
import webbrowser
import subprocess
import os, time
for i in Final_Bioteck[6:11]:
webbrowser.open( '{}.png'.format(i)) # opens the pic
time.sleep(3)
subprocess.run(['taskkill', '/f', '/im', "i_view64.exe"])
#taskkill kills the program, '/f' indiciates it's a process, '/'im' (not entirely sure), and i_view64.exe is the image viewers' exe file.
在Windows10,过程是dllhost.exe
使用与 Moondra 相同的脚本,除了使用“dllhost.exe”而不是“i_view64.exe”
import webbrowser
import subprocess
import os, time
for i in Final_Bioteck[6:11]:
webbrowser.open( '{}.png'.format(i)) # opens the pic
time.sleep(3)
subprocess.run(['taskkill', '/f', '/im', "dllhost.exe"])
#taskkill kills the program, '/f' indicates it's a process, '/'im' (indicates the name of the image process), and "dllhost.exe" is the image viewers' exe file.
我试图在每次迭代中关闭通过迭代打开的每个图像。
我在下面提到了这个线程,但正确的答案没有产生结果。
我的代码
for i in Final_Bioteck[:5]:
with Image.open('{}_screenshot.png'.format(i)) as test_image:
test_image.show()
time.sleep(2)
我也试过了,
test_image.close()
,但没有结果。
我上面的循环打开了 5 个 Windows 照片查看器对话框;我希望通过迭代,每个 window 都会被关闭。
我也看到了这个帖子,但是答案已经过时了,所以不确定是否有更简单的方法来执行我想要的。 How can I close an image shown to the user with the Python Imaging Library?
谢谢=)
可以使用,但我在 Windows 上安装了不同的图像查看器,因为我找不到默认查看器的 .exe。
import webbrowser
import subprocess
import os, time
for i in Final_Bioteck[6:11]:
webbrowser.open( '{}.png'.format(i)) # opens the pic
time.sleep(3)
subprocess.run(['taskkill', '/f', '/im', "i_view64.exe"])
#taskkill kills the program, '/f' indiciates it's a process, '/'im' (not entirely sure), and i_view64.exe is the image viewers' exe file.
在Windows10,过程是dllhost.exe 使用与 Moondra 相同的脚本,除了使用“dllhost.exe”而不是“i_view64.exe”
import webbrowser
import subprocess
import os, time
for i in Final_Bioteck[6:11]:
webbrowser.open( '{}.png'.format(i)) # opens the pic
time.sleep(3)
subprocess.run(['taskkill', '/f', '/im', "dllhost.exe"])
#taskkill kills the program, '/f' indicates it's a process, '/'im' (indicates the name of the image process), and "dllhost.exe" is the image viewers' exe file.