We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Image.show() problem with I;16 mode TIFFs
<!--
Thank you for reporting an issue.

Follow these guidelines to ensure your issue is handled properly.

If you have a ...

1.  General question: consider asking the question on Stack Overflow
    with the python-imaging-library tag:

    * https://stackoverflow.com/questions/tagged/python-imaging-library

    Do not ask a question in both places.

    If you think you have found a bug or have an unexplained exception
    then file a bug report here.

2.  Bug report: include a self-contained, copy-pastable example that
    generates the issue if possible. Be concise with code posted.
    Guidelines on how to provide a good bug report:

    * https://stackoverflow.com/help/mcve

    Bug reports which follow these guidelines are easier to diagnose,
    and are often handled much more quickly.

3.  Feature request: do a quick search of existing issues
    to make sure this has not been asked before.

We know asking good questions takes effort, and we appreciate your time.
Thank you.
-->

### What did you do?

Loaded a 16 bit integer TIFF file and showed it.

### What did you expect to happen?

That the image looks exactly the same as when opened manually.

### What actually happened?

It looked very different. 

I can't share the original image I am working with, but it becomes almost completely white, whereas it was mostly black before. 

I generated another example (code below). I can't upload it here, because GitHub doesn't accept .tif. 

The black one on the left side is the actual correct one opened manually.

![Screenshot ](https://user-images.githubusercontent.com/62176388/85736642-f2d1b700-b6fe-11ea-9528-e196d0e89138.png)

 The problem might be the temporary conversion to BMP. (Uneducated guess)

### What are your OS, Python and Pillow versions?

* OS: Windows 10 and WSL Ubuntu 18.04
* Python: 3.8.2
* Pillow: 7.1.2

<!--
Please include **code** that reproduces the issue and whenever possible, an **image** that demonstrates the issue. Please upload images to GitHub, not to third-party file hosting sites. If necessary, add the image to a zip or tar archive.

The best reproductions are self-contained scripts with minimal dependencies. If you are using a framework such as Plone, Django, or Buildout, try to replicate the issue just using Pillow.
-->

```python
from PIL import Image 

# code used to generate the example image
# img = Image.new('I;16', (1000,1000), 70)

# code that causes issue
with Image.open('test_generated.tif') as img:
    print(img.mode) # I;16
    print(img.format) # TIFF 
    img.show()
```

EDIT:
[test_generated.zip](https://github.com/python-pillow/Pillow/files/4836715/test_generated.zip)


--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `src/PIL/ImageShow.py`
Content:
```
1 #
2 # The Python Imaging Library.
3 # $Id$
4 #
5 # im.show() drivers
6 #
7 # History:
8 # 2008-04-06 fl   Created
9 #
10 # Copyright (c) Secret Labs AB 2008.
11 #
12 # See the README file for information on usage and redistribution.
13 #
14 import os
15 import shutil
16 import subprocess
17 import sys
18 import tempfile
19 from shlex import quote
20 
21 from PIL import Image
22 
23 _viewers = []
24 
25 
26 def register(viewer, order=1):
27     """
28     The :py:func:`register` function is used to register additional viewers.
29 
30     :param viewer: The viewer to be registered.
31     :param order:
32         Zero or a negative integer to prepend this viewer to the list,
33         a positive integer to append it.
34     """
35     try:
36         if issubclass(viewer, Viewer):
37             viewer = viewer()
38     except TypeError:
39         pass  # raised if viewer wasn't a class
40     if order > 0:
41         _viewers.append(viewer)
42     else:
43         _viewers.insert(0, viewer)
44 
45 
46 def show(image, title=None, **options):
47     r"""
48     Display a given image.
49 
50     :param image: An image object.
51     :param title: Optional title. Not all viewers can display the title.
52     :param \**options: Additional viewer options.
53     :returns: ``True`` if a suitable viewer was found, ``False`` otherwise.
54     """
55     for viewer in _viewers:
56         if viewer.show(image, title=title, **options):
57             return 1
58     return 0
59 
60 
61 class Viewer:
62     """Base class for viewers."""
63 
64     # main api
65 
66     def show(self, image, **options):
67         """
68         The main function for displaying an image.
69         Converts the given image to the target format and displays it.
70         """
71 
72         # save temporary image to disk
73         if not (
74             image.mode in ("1", "RGBA") or (self.format == "PNG" and image.mode == "LA")
75         ):
76             base = Image.getmodebase(image.mode)
77             if image.mode != base:
78                 image = image.convert(base)
79 
80         return self.show_image(image, **options)
81 
82     # hook methods
83 
84     format = None
85     """The format to convert the image into."""
86     options = {}
87     """Additional options used to convert the image."""
88 
89     def get_format(self, image):
90         """Return format name, or ``None`` to save as PGM/PPM."""
91         return self.format
92 
93     def get_command(self, file, **options):
94         """
95         Returns the command used to display the file.
96         Not implemented in the base class.
97         """
98         raise NotImplementedError
99 
100     def save_image(self, image):
101         """Save to temporary file and return filename."""
102         return image._dump(format=self.get_format(image), **self.options)
103 
104     def show_image(self, image, **options):
105         """Display the given image."""
106         return self.show_file(self.save_image(image), **options)
107 
108     def show_file(self, file, **options):
109         """Display the given file."""
110         os.system(self.get_command(file, **options))
111         return 1
112 
113 
114 # --------------------------------------------------------------------
115 
116 
117 class WindowsViewer(Viewer):
118     """The default viewer on Windows is the default system application for PNG files."""
119 
120     format = "PNG"
121     options = {"compress_level": 1}
122 
123     def get_command(self, file, **options):
124         return (
125             'start "Pillow" /WAIT "%s" '
126             "&& ping -n 2 127.0.0.1 >NUL "
127             '&& del /f "%s"' % (file, file)
128         )
129 
130 
131 if sys.platform == "win32":
132     register(WindowsViewer)
133 
134 
135 class MacViewer(Viewer):
136     """The default viewer on MacOS using ``Preview.app``."""
137 
138     format = "PNG"
139     options = {"compress_level": 1}
140 
141     def get_command(self, file, **options):
142         # on darwin open returns immediately resulting in the temp
143         # file removal while app is opening
144         command = "open -a Preview.app"
145         command = "({} {}; sleep 20; rm -f {})&".format(
146             command, quote(file), quote(file)
147         )
148         return command
149 
150     def show_file(self, file, **options):
151         """Display given file"""
152         fd, path = tempfile.mkstemp()
153         with os.fdopen(fd, "w") as f:
154             f.write(file)
155         with open(path, "r") as f:
156             subprocess.Popen(
157                 ["im=$(cat); open -a Preview.app $im; sleep 20; rm -f $im"],
158                 shell=True,
159                 stdin=f,
160             )
161         os.remove(path)
162         return 1
163 
164 
165 if sys.platform == "darwin":
166     register(MacViewer)
167 
168 
169 class UnixViewer(Viewer):
170     format = "PNG"
171     options = {"compress_level": 1}
172 
173     def get_command(self, file, **options):
174         command = self.get_command_ex(file, **options)[0]
175         return "({} {}; rm -f {})&".format(command, quote(file), quote(file))
176 
177     def show_file(self, file, **options):
178         """Display given file"""
179         fd, path = tempfile.mkstemp()
180         with os.fdopen(fd, "w") as f:
181             f.write(file)
182         with open(path, "r") as f:
183             command = self.get_command_ex(file, **options)[0]
184             subprocess.Popen(
185                 ["im=$(cat);" + command + " $im; rm -f $im"], shell=True, stdin=f
186             )
187         os.remove(path)
188         return 1
189 
190 
191 class DisplayViewer(UnixViewer):
192     """The ImageMagick ``display`` command."""
193 
194     def get_command_ex(self, file, **options):
195         command = executable = "display"
196         return command, executable
197 
198 
199 class EogViewer(UnixViewer):
200     """The GNOME Image Viewer ``eog`` command."""
201 
202     def get_command_ex(self, file, **options):
203         command = executable = "eog"
204         return command, executable
205 
206 
207 class XVViewer(UnixViewer):
208     """
209     The X Viewer ``xv`` command.
210     This viewer supports the ``title`` parameter.
211     """
212 
213     def get_command_ex(self, file, title=None, **options):
214         # note: xv is pretty outdated.  most modern systems have
215         # imagemagick's display command instead.
216         command = executable = "xv"
217         if title:
218             command += " -name %s" % quote(title)
219         return command, executable
220 
221 
222 if sys.platform not in ("win32", "darwin"):  # unixoids
223     if shutil.which("display"):
224         register(DisplayViewer)
225     if shutil.which("eog"):
226         register(EogViewer)
227     if shutil.which("xv"):
228         register(XVViewer)
229 
230 if __name__ == "__main__":
231 
232     if len(sys.argv) < 2:
233         print("Syntax: python ImageShow.py imagefile [title]")
234         sys.exit()
235 
236     with Image.open(sys.argv[1]) as im:
237         print(show(im, *sys.argv[2:]))
238
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/src/PIL/ImageShow.py b/src/PIL/ImageShow.py
--- a/src/PIL/ImageShow.py
+++ b/src/PIL/ImageShow.py
@@ -71,7 +71,8 @@
 
         # save temporary image to disk
         if not (
-            image.mode in ("1", "RGBA") or (self.format == "PNG" and image.mode == "LA")
+            image.mode in ("1", "RGBA")
+            or (self.format == "PNG" and image.mode in ("I;16", "LA"))
         ):
             base = Image.getmodebase(image.mode)
             if image.mode != base:

{"golden_diff": "diff --git a/src/PIL/ImageShow.py b/src/PIL/ImageShow.py\n--- a/src/PIL/ImageShow.py\n+++ b/src/PIL/ImageShow.py\n@@ -71,7 +71,8 @@\n \n         # save temporary image to disk\n         if not (\n-            image.mode in (\"1\", \"RGBA\") or (self.format == \"PNG\" and image.mode == \"LA\")\n+            image.mode in (\"1\", \"RGBA\")\n+            or (self.format == \"PNG\" and image.mode in (\"I;16\", \"LA\"))\n         ):\n             base = Image.getmodebase(image.mode)\n             if image.mode != base:\n", "issue": "Image.show() problem with I;16 mode TIFFs\n<!--\r\nThank you for reporting an issue.\r\n\r\nFollow these guidelines to ensure your issue is handled properly.\r\n\r\nIf you have a ...\r\n\r\n1.  General question: consider asking the question on Stack Overflow\r\n    with the python-imaging-library tag:\r\n\r\n    * https://stackoverflow.com/questions/tagged/python-imaging-library\r\n\r\n    Do not ask a question in both places.\r\n\r\n    If you think you have found a bug or have an unexplained exception\r\n    then file a bug report here.\r\n\r\n2.  Bug report: include a self-contained, copy-pastable example that\r\n    generates the issue if possible. Be concise with code posted.\r\n    Guidelines on how to provide a good bug report:\r\n\r\n    * https://stackoverflow.com/help/mcve\r\n\r\n    Bug reports which follow these guidelines are easier to diagnose,\r\n    and are often handled much more quickly.\r\n\r\n3.  Feature request: do a quick search of existing issues\r\n    to make sure this has not been asked before.\r\n\r\nWe know asking good questions takes effort, and we appreciate your time.\r\nThank you.\r\n-->\r\n\r\n### What did you do?\r\n\r\nLoaded a 16 bit integer TIFF file and showed it.\r\n\r\n### What did you expect to happen?\r\n\r\nThat the image looks exactly the same as when opened manually.\r\n\r\n### What actually happened?\r\n\r\nIt looked very different. \r\n\r\nI can't share the original image I am working with, but it becomes almost completely white, whereas it was mostly black before. \r\n\r\nI generated another example (code below). I can't upload it here, because GitHub doesn't accept .tif. \r\n\r\nThe black one on the left side is the actual correct one opened manually.\r\n\r\n![Screenshot ](https://user-images.githubusercontent.com/62176388/85736642-f2d1b700-b6fe-11ea-9528-e196d0e89138.png)\r\n\r\n The problem might be the temporary conversion to BMP. (Uneducated guess)\r\n\r\n### What are your OS, Python and Pillow versions?\r\n\r\n* OS: Windows 10 and WSL Ubuntu 18.04\r\n* Python: 3.8.2\r\n* Pillow: 7.1.2\r\n\r\n<!--\r\nPlease include **code** that reproduces the issue and whenever possible, an **image** that demonstrates the issue. Please upload images to GitHub, not to third-party file hosting sites. If necessary, add the image to a zip or tar archive.\r\n\r\nThe best reproductions are self-contained scripts with minimal dependencies. If you are using a framework such as Plone, Django, or Buildout, try to replicate the issue just using Pillow.\r\n-->\r\n\r\n```python\r\nfrom PIL import Image \r\n\r\n# code used to generate the example image\r\n# img = Image.new('I;16', (1000,1000), 70)\r\n\r\n# code that causes issue\r\nwith Image.open('test_generated.tif') as img:\r\n    print(img.mode) # I;16\r\n    print(img.format) # TIFF \r\n    img.show()\r\n```\r\n\r\nEDIT:\r\n[test_generated.zip](https://github.com/python-pillow/Pillow/files/4836715/test_generated.zip)\r\n\n", "before_files": [{"content": "#\n# The Python Imaging Library.\n# $Id$\n#\n# im.show() drivers\n#\n# History:\n# 2008-04-06 fl   Created\n#\n# Copyright (c) Secret Labs AB 2008.\n#\n# See the README file for information on usage and redistribution.\n#\nimport os\nimport shutil\nimport subprocess\nimport sys\nimport tempfile\nfrom shlex import quote\n\nfrom PIL import Image\n\n_viewers = []\n\n\ndef register(viewer, order=1):\n    \"\"\"\n    The :py:func:`register` function is used to register additional viewers.\n\n    :param viewer: The viewer to be registered.\n    :param order:\n        Zero or a negative integer to prepend this viewer to the list,\n        a positive integer to append it.\n    \"\"\"\n    try:\n        if issubclass(viewer, Viewer):\n            viewer = viewer()\n    except TypeError:\n        pass  # raised if viewer wasn't a class\n    if order > 0:\n        _viewers.append(viewer)\n    else:\n        _viewers.insert(0, viewer)\n\n\ndef show(image, title=None, **options):\n    r\"\"\"\n    Display a given image.\n\n    :param image: An image object.\n    :param title: Optional title. Not all viewers can display the title.\n    :param \\**options: Additional viewer options.\n    :returns: ``True`` if a suitable viewer was found, ``False`` otherwise.\n    \"\"\"\n    for viewer in _viewers:\n        if viewer.show(image, title=title, **options):\n            return 1\n    return 0\n\n\nclass Viewer:\n    \"\"\"Base class for viewers.\"\"\"\n\n    # main api\n\n    def show(self, image, **options):\n        \"\"\"\n        The main function for displaying an image.\n        Converts the given image to the target format and displays it.\n        \"\"\"\n\n        # save temporary image to disk\n        if not (\n            image.mode in (\"1\", \"RGBA\") or (self.format == \"PNG\" and image.mode == \"LA\")\n        ):\n            base = Image.getmodebase(image.mode)\n            if image.mode != base:\n                image = image.convert(base)\n\n        return self.show_image(image, **options)\n\n    # hook methods\n\n    format = None\n    \"\"\"The format to convert the image into.\"\"\"\n    options = {}\n    \"\"\"Additional options used to convert the image.\"\"\"\n\n    def get_format(self, image):\n        \"\"\"Return format name, or ``None`` to save as PGM/PPM.\"\"\"\n        return self.format\n\n    def get_command(self, file, **options):\n        \"\"\"\n        Returns the command used to display the file.\n        Not implemented in the base class.\n        \"\"\"\n        raise NotImplementedError\n\n    def save_image(self, image):\n        \"\"\"Save to temporary file and return filename.\"\"\"\n        return image._dump(format=self.get_format(image), **self.options)\n\n    def show_image(self, image, **options):\n        \"\"\"Display the given image.\"\"\"\n        return self.show_file(self.save_image(image), **options)\n\n    def show_file(self, file, **options):\n        \"\"\"Display the given file.\"\"\"\n        os.system(self.get_command(file, **options))\n        return 1\n\n\n# --------------------------------------------------------------------\n\n\nclass WindowsViewer(Viewer):\n    \"\"\"The default viewer on Windows is the default system application for PNG files.\"\"\"\n\n    format = \"PNG\"\n    options = {\"compress_level\": 1}\n\n    def get_command(self, file, **options):\n        return (\n            'start \"Pillow\" /WAIT \"%s\" '\n            \"&& ping -n 2 127.0.0.1 >NUL \"\n            '&& del /f \"%s\"' % (file, file)\n        )\n\n\nif sys.platform == \"win32\":\n    register(WindowsViewer)\n\n\nclass MacViewer(Viewer):\n    \"\"\"The default viewer on MacOS using ``Preview.app``.\"\"\"\n\n    format = \"PNG\"\n    options = {\"compress_level\": 1}\n\n    def get_command(self, file, **options):\n        # on darwin open returns immediately resulting in the temp\n        # file removal while app is opening\n        command = \"open -a Preview.app\"\n        command = \"({} {}; sleep 20; rm -f {})&\".format(\n            command, quote(file), quote(file)\n        )\n        return command\n\n    def show_file(self, file, **options):\n        \"\"\"Display given file\"\"\"\n        fd, path = tempfile.mkstemp()\n        with os.fdopen(fd, \"w\") as f:\n            f.write(file)\n        with open(path, \"r\") as f:\n            subprocess.Popen(\n                [\"im=$(cat); open -a Preview.app $im; sleep 20; rm -f $im\"],\n                shell=True,\n                stdin=f,\n            )\n        os.remove(path)\n        return 1\n\n\nif sys.platform == \"darwin\":\n    register(MacViewer)\n\n\nclass UnixViewer(Viewer):\n    format = \"PNG\"\n    options = {\"compress_level\": 1}\n\n    def get_command(self, file, **options):\n        command = self.get_command_ex(file, **options)[0]\n        return \"({} {}; rm -f {})&\".format(command, quote(file), quote(file))\n\n    def show_file(self, file, **options):\n        \"\"\"Display given file\"\"\"\n        fd, path = tempfile.mkstemp()\n        with os.fdopen(fd, \"w\") as f:\n            f.write(file)\n        with open(path, \"r\") as f:\n            command = self.get_command_ex(file, **options)[0]\n            subprocess.Popen(\n                [\"im=$(cat);\" + command + \" $im; rm -f $im\"], shell=True, stdin=f\n            )\n        os.remove(path)\n        return 1\n\n\nclass DisplayViewer(UnixViewer):\n    \"\"\"The ImageMagick ``display`` command.\"\"\"\n\n    def get_command_ex(self, file, **options):\n        command = executable = \"display\"\n        return command, executable\n\n\nclass EogViewer(UnixViewer):\n    \"\"\"The GNOME Image Viewer ``eog`` command.\"\"\"\n\n    def get_command_ex(self, file, **options):\n        command = executable = \"eog\"\n        return command, executable\n\n\nclass XVViewer(UnixViewer):\n    \"\"\"\n    The X Viewer ``xv`` command.\n    This viewer supports the ``title`` parameter.\n    \"\"\"\n\n    def get_command_ex(self, file, title=None, **options):\n        # note: xv is pretty outdated.  most modern systems have\n        # imagemagick's display command instead.\n        command = executable = \"xv\"\n        if title:\n            command += \" -name %s\" % quote(title)\n        return command, executable\n\n\nif sys.platform not in (\"win32\", \"darwin\"):  # unixoids\n    if shutil.which(\"display\"):\n        register(DisplayViewer)\n    if shutil.which(\"eog\"):\n        register(EogViewer)\n    if shutil.which(\"xv\"):\n        register(XVViewer)\n\nif __name__ == \"__main__\":\n\n    if len(sys.argv) < 2:\n        print(\"Syntax: python ImageShow.py imagefile [title]\")\n        sys.exit()\n\n    with Image.open(sys.argv[1]) as im:\n        print(show(im, *sys.argv[2:]))\n", "path": "src/PIL/ImageShow.py"}], "after_files": [{"content": "#\n# The Python Imaging Library.\n# $Id$\n#\n# im.show() drivers\n#\n# History:\n# 2008-04-06 fl   Created\n#\n# Copyright (c) Secret Labs AB 2008.\n#\n# See the README file for information on usage and redistribution.\n#\nimport os\nimport shutil\nimport subprocess\nimport sys\nimport tempfile\nfrom shlex import quote\n\nfrom PIL import Image\n\n_viewers = []\n\n\ndef register(viewer, order=1):\n    \"\"\"\n    The :py:func:`register` function is used to register additional viewers.\n\n    :param viewer: The viewer to be registered.\n    :param order:\n        Zero or a negative integer to prepend this viewer to the list,\n        a positive integer to append it.\n    \"\"\"\n    try:\n        if issubclass(viewer, Viewer):\n            viewer = viewer()\n    except TypeError:\n        pass  # raised if viewer wasn't a class\n    if order > 0:\n        _viewers.append(viewer)\n    else:\n        _viewers.insert(0, viewer)\n\n\ndef show(image, title=None, **options):\n    r\"\"\"\n    Display a given image.\n\n    :param image: An image object.\n    :param title: Optional title. Not all viewers can display the title.\n    :param \\**options: Additional viewer options.\n    :returns: ``True`` if a suitable viewer was found, ``False`` otherwise.\n    \"\"\"\n    for viewer in _viewers:\n        if viewer.show(image, title=title, **options):\n            return 1\n    return 0\n\n\nclass Viewer:\n    \"\"\"Base class for viewers.\"\"\"\n\n    # main api\n\n    def show(self, image, **options):\n        \"\"\"\n        The main function for displaying an image.\n        Converts the given image to the target format and displays it.\n        \"\"\"\n\n        # save temporary image to disk\n        if not (\n            image.mode in (\"1\", \"RGBA\")\n            or (self.format == \"PNG\" and image.mode in (\"I;16\", \"LA\"))\n        ):\n            base = Image.getmodebase(image.mode)\n            if image.mode != base:\n                image = image.convert(base)\n\n        return self.show_image(image, **options)\n\n    # hook methods\n\n    format = None\n    \"\"\"The format to convert the image into.\"\"\"\n    options = {}\n    \"\"\"Additional options used to convert the image.\"\"\"\n\n    def get_format(self, image):\n        \"\"\"Return format name, or ``None`` to save as PGM/PPM.\"\"\"\n        return self.format\n\n    def get_command(self, file, **options):\n        \"\"\"\n        Returns the command used to display the file.\n        Not implemented in the base class.\n        \"\"\"\n        raise NotImplementedError\n\n    def save_image(self, image):\n        \"\"\"Save to temporary file and return filename.\"\"\"\n        return image._dump(format=self.get_format(image), **self.options)\n\n    def show_image(self, image, **options):\n        \"\"\"Display the given image.\"\"\"\n        return self.show_file(self.save_image(image), **options)\n\n    def show_file(self, file, **options):\n        \"\"\"Display the given file.\"\"\"\n        os.system(self.get_command(file, **options))\n        return 1\n\n\n# --------------------------------------------------------------------\n\n\nclass WindowsViewer(Viewer):\n    \"\"\"The default viewer on Windows is the default system application for PNG files.\"\"\"\n\n    format = \"PNG\"\n    options = {\"compress_level\": 1}\n\n    def get_command(self, file, **options):\n        return (\n            'start \"Pillow\" /WAIT \"%s\" '\n            \"&& ping -n 2 127.0.0.1 >NUL \"\n            '&& del /f \"%s\"' % (file, file)\n        )\n\n\nif sys.platform == \"win32\":\n    register(WindowsViewer)\n\n\nclass MacViewer(Viewer):\n    \"\"\"The default viewer on MacOS using ``Preview.app``.\"\"\"\n\n    format = \"PNG\"\n    options = {\"compress_level\": 1}\n\n    def get_command(self, file, **options):\n        # on darwin open returns immediately resulting in the temp\n        # file removal while app is opening\n        command = \"open -a Preview.app\"\n        command = \"({} {}; sleep 20; rm -f {})&\".format(\n            command, quote(file), quote(file)\n        )\n        return command\n\n    def show_file(self, file, **options):\n        \"\"\"Display given file\"\"\"\n        fd, path = tempfile.mkstemp()\n        with os.fdopen(fd, \"w\") as f:\n            f.write(file)\n        with open(path, \"r\") as f:\n            subprocess.Popen(\n                [\"im=$(cat); open -a Preview.app $im; sleep 20; rm -f $im\"],\n                shell=True,\n                stdin=f,\n            )\n        os.remove(path)\n        return 1\n\n\nif sys.platform == \"darwin\":\n    register(MacViewer)\n\n\nclass UnixViewer(Viewer):\n    format = \"PNG\"\n    options = {\"compress_level\": 1}\n\n    def get_command(self, file, **options):\n        command = self.get_command_ex(file, **options)[0]\n        return \"({} {}; rm -f {})&\".format(command, quote(file), quote(file))\n\n    def show_file(self, file, **options):\n        \"\"\"Display given file\"\"\"\n        fd, path = tempfile.mkstemp()\n        with os.fdopen(fd, \"w\") as f:\n            f.write(file)\n        with open(path, \"r\") as f:\n            command = self.get_command_ex(file, **options)[0]\n            subprocess.Popen(\n                [\"im=$(cat);\" + command + \" $im; rm -f $im\"], shell=True, stdin=f\n            )\n        os.remove(path)\n        return 1\n\n\nclass DisplayViewer(UnixViewer):\n    \"\"\"The ImageMagick ``display`` command.\"\"\"\n\n    def get_command_ex(self, file, **options):\n        command = executable = \"display\"\n        return command, executable\n\n\nclass EogViewer(UnixViewer):\n    \"\"\"The GNOME Image Viewer ``eog`` command.\"\"\"\n\n    def get_command_ex(self, file, **options):\n        command = executable = \"eog\"\n        return command, executable\n\n\nclass XVViewer(UnixViewer):\n    \"\"\"\n    The X Viewer ``xv`` command.\n    This viewer supports the ``title`` parameter.\n    \"\"\"\n\n    def get_command_ex(self, file, title=None, **options):\n        # note: xv is pretty outdated.  most modern systems have\n        # imagemagick's display command instead.\n        command = executable = \"xv\"\n        if title:\n            command += \" -name %s\" % quote(title)\n        return command, executable\n\n\nif sys.platform not in (\"win32\", \"darwin\"):  # unixoids\n    if shutil.which(\"display\"):\n        register(DisplayViewer)\n    if shutil.which(\"eog\"):\n        register(EogViewer)\n    if shutil.which(\"xv\"):\n        register(XVViewer)\n\nif __name__ == \"__main__\":\n\n    if len(sys.argv) < 2:\n        print(\"Syntax: python ImageShow.py imagefile [title]\")\n        sys.exit()\n\n    with Image.open(sys.argv[1]) as im:\n        print(show(im, *sys.argv[2:]))\n", "path": "src/PIL/ImageShow.py"}]}