The PIL show() method looks for the default viewer. How do I change this to a different viewer (of my choice)?

Peter J. Holzer hjp-python at hjp.at
Tue May 29 05:50:50 EDT 2018


On 2018-05-28 06:34:30 +0200, Christian Gollwitzer wrote:
> I think this is a bug/misfeature in the PIL code. On all 3 major platforms
> there is a way to invoke the standard program for a given file or URL. On
> Windows, it is "cmd.exe /c start ...", on OSX it is "open ...." and on Linux
> it is "xdg-open ...". That way the file is opened by whatever the user has
> set in his desktop environment.
> 
> Technically, xdg-open needs not to be present on Linux, though it is usually
> installed.

xv and display don't need to be installed either. In fact, xv is
unlikely to be installed (it's non-free (shareware) and hasn't been
maintained in ages[1]). Display is part of imagemagick, which is also
optional (though quite likely to be installed - among other things CUPS
depends on it). And display isn't very useful either (for example, there
doesn't seem to be a way to scale down large images to the size of the
display).

OTOH, xdg-open is part of the free desktop specification, so if you have
any kind of linux desktop, it is very probable that you have xdg-open
and that it is reasonably configured.

I agree that show should call xdg-open preferentially and maybe fall
back to display. And of course silently ignoring a documented parameter
is clearly a bug (if it's true - I notice that the Pillow docs don't mention
that parameter and the original PIL seems to unmaintained).

        hp

[1] Which is a pity, because I loved it.


-- 
   _  | Peter J. Holzer    | we build much bigger, better disasters now
|_|_) |                    | because we have much more sophisticated
| |   | hjp at hjp.at         | management tools.
__/   | http://www.hjp.at/ | -- Ross Anderson <https://www.edge.org/>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/python-list/attachments/20180529/5586ad36/attachment.sig>


More information about the Python-list mailing list