ImageShow
Module¶
The ImageShow
Module is used to display images.
All default viewers convert the image to be shown to PNG format.
- PIL.ImageShow.show(image: Image, title: str | None = None, **options: Any) bool [source]¶
Display a given image.
- Parameters:
image – An image object.
title – Optional title. Not all viewers can display the title.
**options – Additional viewer options.
- Returns:
True
if a suitable viewer was found,False
otherwise.
- class PIL.ImageShow.WindowsViewer[source]¶
The default viewer on Windows is the default system application for PNG files.
- class PIL.ImageShow.UnixViewer[source]¶
The following viewers may be registered on Unix-based systems, if the given command is found:
- class XDGViewer¶
The freedesktop.org
xdg-open
command.
- class DisplayViewer¶
The ImageMagick
display
command. This viewer supports thetitle
parameter.
- class GmDisplayViewer¶
The GraphicsMagick
gm display
command.
- class EogViewer¶
The GNOME Image Viewer
eog
command.
- class XVViewer¶
The X Viewer
xv
command. This viewer supports thetitle
parameter.
To provide maximum functionality on Unix-based systems, temporary files created from images will not be automatically removed by Pillow.
- PIL.ImageShow.register(viewer: type[Viewer] | Viewer, order: int = 1) None [source]¶
The
register()
function is used to register additional viewers:from PIL import ImageShow ImageShow.register(MyViewer()) # MyViewer will be used as a last resort ImageShow.register(MySecondViewer(), 0) # MySecondViewer will be prioritised ImageShow.register(ImageShow.XVViewer(), 0) # XVViewer will be prioritised
- Parameters:
viewer – The viewer to be registered.
order – Zero or a negative integer to prepend this viewer to the list, a positive integer to append it.
- class PIL.ImageShow.Viewer[source]¶
Base class for viewers.
- show(image: Image, **options: Any) int [source]¶
The main function for displaying an image. Converts the given image to the target format and displays it.