Extract EXIF Data from Photos using Python

How to extract the metadata from images using Pillow Library

Abhijith Chandradas
Geek Culture
Published in
3 min readMar 14, 2022


What is EXIF data?

EXIF stands for ‘Exchangeable Image File Format’ and refers to the basic metadata that is generated and stored by your camera whenever you take a photo.
EXIF data in photography is generally used to refer the aperture, shutter speed, ISO, metering, white balance, camera model, lens specifications etc. of a photo.
Modern cameras, and mobile phones stores EXIF data and other important information viz- software used for processing, GPS information, make and model of the camera etc. For more information about EXIF data, refer this article.
All major social media platforms sanitize the photos uploaded by users of the metadata. Sanitizing the images is very important as the metadata could reveal critical information.
This article explains how to extract EXIF data from photos using python.

Import Libraries

The only library required to extract the EXIF data is pillow library. If pillow is not installed, it should be installed as given in Pillow Documentation.

from PIL import Image
from PIL.ExifTags import TAGS

Image module of pillow is used to read/open the photo.
from ExifTags module of Pillow should also imported for understanding and decoding the exif data.

What are the Metadata which can be extracted?

The details of all metadata elements which can be extracted can be obtained by just printing out the TAGS. TAGS is in the form of a dictionary with the metadata item as the value and unique key for each item.

{11: 'ProcessingSoftware',
254: 'NewSubfileType',
255: 'SubfileType',
256: 'ImageWidth' . . . . . }

The current version of pillow can extract 260 metadata items.

Open Image

The following command can be used to open an image named as ‘img.jpg’ in the same directory as the code.


Getting exif data

The exif data can be extracted using getexif function. The data can be viewed…



Abhijith Chandradas
Geek Culture

Data Analyst | Hacker | Financial Analyst | Freelancer | IIM MBA | Opensource | Democratize Knowledge | https://www.youtube.com/channel/UCLpBd4gzfIBXm2BPpdHOWdQ