Get Image Filename with Pillow in Python

Pillow – Get Image Filename

To get the filename of an image with Pillow in Python, you can use PIL.Image.filename attribute.

The attribute returns the filename or path of the source file.


1. Get file name of given image

In the following program, we open an image using, and then get the filename of the image using filename attribute of Image class object.

Python Program

from PIL import Image

# Open an image
img ="test_image_house.jpg")

# Get image file name
filename = img.filename




In this Python Pillow Tutorial, we learned how to get the filename of an image using PIL.Image.filename attribute, with the help of examples.

Related Tutorials

Code copied to clipboard successfully 👍