在Python中保存图像的最佳格式是什么,为什么pydot会保存无效图像?

1 python image

pydot用来在我的机器上保存图像文件,然后使用Image模块打开文件.但是,我收到错误Windows Photo viewer.无法打开图像,因为它已被删除或位于不可用的位置.这是不正确的,因为图像保存到我的桌面.

有时,随机地,图片确实被打开,但需要花费很多时间.为什么我会遇到这个问题?

我可以选择以任何格式保存图像.是否存在可以保存的图像格式,通过Python打开的时间相对较少,或者所有格式都需要同时进行?

cgo*_*lke 5

这看起来像是Windows Vista/7上PIL图像查看器中的已知错误.您可以尝试修复PIL/ImageShow.py,如下所示:

diff -r 142e08f1b589 PIL/ImageShow.py
--- a/PIL/ImageShow.py  Sun Aug 01 22:00:26 2010 +0200
+++ b/PIL/ImageShow.py  Wed Jan 05 10:46:47 2011 -0800
@@ -97,7 +97,7 @@
     class WindowsViewer(Viewer):
         format = "BMP"
         def get_command(self, file, **options):
-            return "start /wait %s && del /f %s" % (file, file)
+            return "start /wait %s && ping -n 2 127.0.0.1 >NUL && del /f %s" % (file, file)

     register(WindowsViewer)
Run Code Online (Sandbox Code Playgroud)