Python PIL Image.show() Method
Python PIL Image.show() Method
PIL is the Python Imaging Library, which provides image editing capabilities for the Python interpreter. The Image module provides a class of the same name to represent a PIL image. The module also provides factory functions for loading images from files and creating new images.
Image.show() displays the image. This method is primarily for debugging purposes.
On Unix platforms, this method saves the image to a temporary PPM file and calls the xv utility. On Windows, it saves the image to a temporary BMP file and displays it using a standard BMP display tool (typically Paint).
Syntax: Image.show(title=None, command=None)
Parameters:
title – An optional title to use for the image window, if applicable.
command – The command used to display the image.
Return Type = The image at the specified path will be opened.
Image used:
# importing Image class from PIL package
from PIL import Image
# creating an object
im = Image.open(r"C:UsersSystem-PcDesktophome.png")
im.show()
Output:
Another example: Use show() to open an image with a .jpg extension.
Image used:
# Importing Image class from PIL package
from PIL import Image
# Creating an object
im = Image.open(r"C:UsersSystem-PcDesktoptree.jpg")
im.show()
Output: