diff --git a/docs/reference/ImageShow.rst b/docs/reference/ImageShow.rst index e4d9805ab4c..45b50c8469b 100644 --- a/docs/reference/ImageShow.rst +++ b/docs/reference/ImageShow.rst @@ -17,6 +17,7 @@ All default viewers convert the image to be shown to PNG format. The following viewers may be registered on Unix-based systems, if the given command is found: + .. autoclass:: PIL.ImageShow.XDGViewer .. autoclass:: PIL.ImageShow.DisplayViewer .. autoclass:: PIL.ImageShow.GmDisplayViewer .. autoclass:: PIL.ImageShow.EogViewer diff --git a/src/PIL/ImageShow.py b/src/PIL/ImageShow.py index cd0737c3693..2135293e5eb 100644 --- a/src/PIL/ImageShow.py +++ b/src/PIL/ImageShow.py @@ -186,6 +186,16 @@ def show_file(self, file, **options): return 1 +class XDGViewer(UnixViewer): + """ + The freedesktop.org ``xdg-open`` command. + """ + + def get_command_ex(self, file, **options): + command = executable = "xdg-open" + return command, executable + + class DisplayViewer(UnixViewer): """ The ImageMagick ``display`` command. @@ -233,6 +243,8 @@ def get_command_ex(self, file, title=None, **options): if sys.platform not in ("win32", "darwin"): # unixoids + if shutil.which("xdg-open"): + register(XDGViewer) if shutil.which("display"): register(DisplayViewer) if shutil.which("gm"):