How to display images on the screen in Python

In this tutorial we are going to see the methods to show an image on the device screen using python, let’s first start the tutorial with an introduction to Python.


Python is the most developed and widely used programming language that Programmers commonly use all over the world. Python is mainly used in machine learning, artificial Intelligence, and Robotics.

Furthermore, Python enables us to import various models that perform distinct tasks it has a wide range of libraries and packages that are used to increase the performance and efficiency of the Python Applications.

Python is an easy-to-understand and easy-to-handle programming language it has the most straightforward syntax that is quite similar to C and C++.

If we talk about displaying images python provides a module that is perfect for displaying image tasks. Check out the module below.

Display images on the screen in Python

(PIL) PillowLibrary

Pillow is an imaging module in Python that reads a jpg and png image formats and manipulates or displays it on screen. The show() and open() functions are used in the Pillow module to show an image.

Let’s move forward to our main topic and see how to display images by using the pillow module check out the example below.


#importing image class from PIL
from PIL import Image
# creating a method
image1 ="C:/Users/PHPERRORCode/Desktop/library.jpg")

Code Explanation

In the above code, we first imported the image class from the PIL module and then we created an object by using the function, the will read the format of the image. The function supports more than 30 formats. 

In the method we specified the path of the image that we want to display, at the end we just displayed the images by using the show function.



As you can see above the image is displaying.


In this tutorial, we talked about the method that we can use to display an image using python. First of all, we discussed an introduction to Python, and then we saw the usage of the Pillow Library.

We understood the concept of Pillow Library in Python Programming with examples.

We also discussed and understood the python code examples using Pillow library “PIL“ with explanations as well at the end we saw their output results also.

That’s all for today hope you like the tutorial if you have any queries regarding this tutorial so feel free to contact us below. Thanks for reading.

Leave a Comment