What is the best format to save an image in Python, and why does pydot save invalid images?
I 开发者_如何学Goam using pydot
to save an image file on my machine and then use the Image module to open the file. However, I get an error using Windows Photo viewer
. The image cannot be opened because it is deleted or is in unavailable location. This is incorrect as the image gets saved to my Desktop.
Sometimes, randomly, the picture does gets opened, but takes a lot of time. Why am I getting this problem?
I have an option to save the image in any format. Is there an image format that one could save that would take comparatively less time opening via Python, or do all formats take the same time?
This looks like a known bug in the image viewer of PIL on Windows Vista/7. You can try to fix PIL/ImageShow.py as follows:
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)
精彩评论