[Image-SIG] im.show() using eog doesn't work second time

Dan Halbert halbert at halwitz.org
Wed Jun 3 00:28:23 CEST 2009


I'm using PIL 1.1.6 on Ubuntu jaunty, and noticed a problem with invoking im.show() more than once without closing the image viewing window. On this system, im.show() uses "eog" to view the images. If you do something like:

>>>im.show()  # don't close the eog window
>>>im.show()

then the second im.show() causes an error. The actual images don't matter: they could be the same or different.

The two im.show() calls invoke Image._showxv() twice, which effectively does this:

   os.system("(eog /tmp/tmp123; rm -f /tmp/tmp123)&")
   os.system("(eog /tmp/tmp456; rm -f /tmp/tmp456)&")

However, eog is very clever and tries to reuse its first instance. So the second instantiation of eog exits immediately after notifying the first to display /tmp/tmp456. But then the file disappears out from under it.

The _showxv() code shows a similar problem already came up on OS X, and a "sleep 20" was inserted before the "rm". For eog, another, perhaps more elegant solution is to invoke eog as "eog -n", which always starts a new instance instead of reusing an existing one.

Regards,
Dan



More information about the Image-SIG mailing list