Pil's Image.show() Brings Up *two* Different Viewers
Solution 1:
A little out-off-dated but...
I solved this problem changing the code of file /usr/lib/python2.7/dist-packages/PIL/ImageShow.py
. Is missing a return
on method show
of Viewer
class (near line 66): return self.show_image(image, **options)
.
Solution 2:
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'.
Solution 3:
A sort of a workaround I found.
I used:
image.save('something.png')
Opened the png from the file manager using the default preview program.
Then every time I called save
again, the previewer automatically refreshed, and I got the new image :)
Solution 4:
ImageShow
has a list of supported and available viewers in ImageShow._viewers
. On my box, two viewers are found:
>>>import PIL.ImageShow>>>PIL.ImageShow._viewers
[<PIL.ImageShow.DisplayViewer instance at 0x2587ef0>, <PIL.ImageShow.XVViewer instance at 0x2587f80>]
Unfortunately ImageShow.show()
uses all available viewers. Thus two windows are displayed.
A solution is to reduce the viewer registry to only the first available viewer:
>>>PIL.ImageShow._viewers = [ PIL.ImageShow._viewers[0] ]
Solution 5:
it is able to specify the viewer as command
argument to the show
method, e.g.
img.show(command='feh')
Post a Comment for "Pil's Image.show() Brings Up *two* Different Viewers"