tags:

views:

37

answers:

2

When toying with images in the python shell, I use image.show(), where image is an instance of Image. Long ago nothing happened, but after defining a symlink to mirage named "xv", I was happy.

The last few days, show() will bring up both ImageMagick's display and also Mirage. It's not clear where show() gets information on what to run. Documentation wasn't helpful. How to make it behave and bring up only what it thinks is xv?

+1  A: 

Well, for one thing, im.show is only intended for debugging purpose, it isn't guaranteed to work.

Nevertheless, you can always look at the source (open "pydoc PIL", the FILE section points out where a module is located):

In Windows, PIL will use "start /wait filename"

In Macs, it uses "open -a /Applications/Preview.app"

and on Linux, either 'display' if found or otherwise 'xdg-open'.

Lie Ryan
The fun part is figuring out why *two* apps get started. The source shows several lines like "if blah-blah-app exists, register it as a viewer" with no "else" separating them. Multiple viewing apps are put in a list and each is invoked. Odd design! I have display and mirage in /usr/bin but didn't have trouble because, I now realize, I haven't done much with PIL since months ago.
DarenW
Yes, please look at ImageShow.py. The show() function will go through the list of registered viewers, and run them one-by-one. A proper registered viewers must return True when its viewer.show() is called, since that signals ImageShow's show() to stop trying other viewers. One of your registered viewers must be succeeded in showing the image but returns False, which causes PIL to try another viewer.
Lie Ryan
A: 

it is able to specify the viewer as command argument to the show method, e.g.

img.show(command='feh')

mykhal
Hmm, that has no effect. Still get display and mirage, and not, say, gimp if I give that as a command.
DarenW