Python imaging library show() on Windows

show() tries to execute the default image viewer with a start /wait command on a temporary image file. The /wait parameter is supposed to wait until the viewer exits, so that the file can be deleted. Unfortunately the default viewer under Vista and Windows 7 does not respond properly to /wait and return even before they’ve opened the file; the file gets deleted before it can be displayed.

The usual fix is to edit ImageShow.py in the PIL package and add an extra command to wait a few seconds before deleting the file. This is a kludge, but it works most of the time. Details at velocityreviews.com and here at StackOverflow.

The other way to fix it is to associate the .bmp file format with a program that waits properly before returning, for example mspaint.exe.

Leave a Comment