from PIL import Image
from PIL.ExifTags import TAGS
# path to the image or video
imagename = "image.jpg"
# read the image data using PIL
image = Image.open(imagename)
# extract EXIF data
exifdata = image.getexif()
# iterating over all EXIF data fields
for tag_id in exifdata:
# get the tag name, instead of human unreadable tag id
tag = TAGS.get(tag_id, tag_id)
data = exifdata.get(tag_id)
# decode bytes
if isinstance(data, bytes):
data = data.decode()
print(f"{tag:25}: {data}")
ExifVersion : 0220 ComponentsConfiguration : ShutterSpeedValue : (1345, 100) DateTimeOriginal : 2020:08:27 09:43:15 DateTimeDigitized : 2020:08:27 09:43:15 ApertureValue : (185, 100) BrightnessValue : (930, 100) ExposureBiasValue : (0, 10) MaxApertureValue : (185, 100) MeteringMode : 2 Flash : 0 FocalLength : (358, 100) UserComment : ColorSpace : 1 ExifImageWidth : 4128 SceneCaptureType : 0 SubsecTime : 0424 SubsecTimeOriginal : 0424 SubsecTimeDigitized : 0424 ExifImageHeight : 1908 ImageLength : 1908 Make : samsung Model : SM-M305F Orientation : 6 YCbCrPositioning : 1 ExposureTime : (1, 2786) ExifInteroperabilityOffset: 944 XResolution : (72, 1) FNumber : (190, 100) SceneType : YResolution : (72, 1) ImageUniqueID : E13LLLI00PM E13LLMK03PA
ExposureProgram : 2 CustomRendered : 0 ISOSpeedRatings : 40 ResolutionUnit : 2 ExposureMode : 0 FlashPixVersion : 0100 ImageWidth : 4128 WhiteBalance : 0 Software : M305FDDU5CTF2 DateTime : 2020:08:27 09:43:15 DigitalZoomRatio : (0, 0) FocalLengthIn35mmFilm : 27 Contrast : 0 Saturation : 0 Sharpness : 0 ExifOffset : 226 MakerNote : 0100 Z@P