On 6/30/2011 9:23 AM, Jean-Claude Arbaut wrote:
I just installed Python 2.7.2 and PIL 1.1.7. In pil-handbook.pdf there
is a trivial example (slightly modified here to change image name):

import Image
im = Image.open("fruit.ppm")
im.show()

Everything runs well, except I get an error from Windows image viewer,
saying the file has been deleted.
The problem seems to come from line 99 in ImageShow.py,
return "start /wait %s && del /f %s" % (file, file)
Looks like the del doesn't wait for start to finish, hence the file
doesn't exist when the viewer
is launched. If I try instead :
return "start /wait %s" % file
Then the image is shown as expected. So there is a workaround, but the
file is not
destroyed afterwards.

Is there a cleaner way to solve the problem, e.g. forcing a wait before
del ?



This is a known issue. A possible solution is to sleep about a second before deleting the file, e.g.:

return "start /wait %s && sleep 1 && del /f %s" % (file, file)

<http://stackoverflow.com/questions/4607633/image-format-to-save-in-python>

Christoph


_______________________________________________
Image-SIG maillist  -  [email protected]
http://mail.python.org/mailman/listinfo/image-sig

Reply via email to