Movatterモバイル変換


[0]ホーム

URL:


ContentsMenuExpandLight modeDark modeAuto light/dark, in light modeAuto light/dark, in dark modeSkip to content
Pillow (PIL Fork) 12.0.0 documentation
Light LogoDark Logo
Pillow (PIL Fork) 12.0.0 documentation
Back to top

ImageShow module

TheImageShow 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.

classPIL.ImageShow.IPythonViewer[source]

The viewer for IPython frontends.

classPIL.ImageShow.WindowsViewer[source]

The default viewer on Windows is the default system application for PNG files.

classPIL.ImageShow.MacViewer[source]

The default viewer on macOS usingPreview.app.

classPIL.ImageShow.UnixViewer[source]

The following viewers may be registered on Unix-based systems, if the given command is found:

classXDGViewer

The freedesktop.orgxdg-open command.

classDisplayViewer

The ImageMagickdisplay command.This viewer supports thetitle parameter.

classGmDisplayViewer

The GraphicsMagickgmdisplay command.

classEogViewer

The GNOME Image Viewereog command.

classXVViewer

The X Viewerxv command.This viewer supports thetitle parameter.

To provide maximum functionality on Unix-based systems, temporary files createdfrom images will not be automatically removed by Pillow.

PIL.ImageShow.register(viewer:type[Viewer]|Viewer,order:int=1)None[source]

Theregister() function is used to register additional viewers:

fromPILimportImageShowImageShow.register(MyViewer())# MyViewer will be used as a last resortImageShow.register(MySecondViewer(),0)# MySecondViewer will be prioritisedImageShow.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.

classPIL.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.

format:str|None=None

The format to convert the image into.

options:dict[str,Any]={}

Additional options used to convert the image.

get_format(image:Image)str|None[source]

Return format name, orNone to save as PGM/PPM.

get_command(file:str,**options:Any)str[source]

Returns the command used to display the file.Not implemented in the base class.

save_image(image:Image)str[source]

Save to temporary file and return filename.

show_image(image:Image,**options:Any)int[source]

Display the given image.

show_file(path:str,**options:Any)int[source]

Display given file.

On this page

[8]ページ先頭

©2009-2025 Movatter.jp