How to open an image from the URL in PIL? Last Updated : 26 Mar, 2021 Improve Improve Like Article Like Save Share Report In this article, we will learn How to open an image from the URL using the PIL module in python. For the opening of the image from a URL in Python, we need two Packages urllib and Pillow(PIL). Approach: Install the required libraries and then import them. To install use the following commands: pip install pillow Copy the URL of any image. Write URL with file name in urllib.request.urlretrieve() method. Use Image.open() method to open image. At last show the image using obj.show() method. Sample Code: import urllib.request from PIL import Image urllib.request.urlretrieve(‘Image url’, “file_name”) img = Image.open(“file_name”) img.show() Example: Python3 # importing modules import urllib.request from PIL import Image urllib.request.urlretrieve( 'https://media.geeksforgeeks.org/wp-content/uploads/20210318103632/gfg-300x300.png', "gfg.png") img = Image.open("gfg.png") img.show() Output: Like Article Suggest improvement Previous How to merge a transparent PNG image with another image using PIL? Next Python - Index Ranks of Elements Share your thoughts in the comments Add Your Comment Please Login to comment...