The following code:

    from PIL import Image
    im = Image.open("img.bmp")
    im.show()


brings up the default Windows 7 Image Viewer. The image viewer does not display 
the image requested, but instead displays "windows photo viewer can't open this 
picture because either the picture is deleted, or it's in a location that isn't 
available".

This site: 
http://www.velocityreviews.com/forums/t707158-python-pil-and-vista-windows-7-show-not-working.html
 has an explanation for this behavior.
What actually happens is that the Windows code relies on the fact that the 
default image viewer on Windows XP was able to work at blocking mode - this 
means that the command will wait until the image window will be closed. Because 
of that behaviour, they constructed a command line which deletes a file right 
after the image has been shown.

Windows Vista doesn't work the same way, it immediately returns once the 
command has been executed, so what happens now is that the temporary file gets 
immediately deleted by the command line, and the image viewer doesn't have 
enough time to load the image before it is being deleted.

Here is a quick workaround:

Edit C:\Python26\lib\site-packages\PIL\ImageShow.py, and around line 99, 
replace with the following line:

return "start /wait %s && PING 127.0.0.1 -n 5 > NUL && del /f %s" % (file, file)



I would like to report this behavior as a bug.

-Chris
_______________________________________________
Image-SIG maillist  -  Image-SIG@python.org
http://mail.python.org/mailman/listinfo/image-sig

Reply via email to