I am trying to read the metadata of my images using Pillow's TAGS functionality. I use the following code to get this information:
# imports
from PIL import Image
from PIL.ExifTags import TAGS
imagename = 'image.jpg'
image = Image.open(imagename)
exifdata = image.getexif()
for tag_id in exifdata:
tag = TAGS.get(tag_id,tag_id)
print(tag_id)
data = exifdata.get(tag_id)
# we decode bytes
if isinstance(data,bytes):
data = data.decode()
print(f'{tag:25}: {data}')
The result I get is similar to the following output:
ImageWidth : 4128
ImageLength : 1908
ResolutionUnit : 2
ExifOffset : 226
Make : samsung
Model : SM-M205F
Software : M205FDDS8CUC1
Orientation : 8
DateTime : 2021:06:18 12:08:37
YCbCrPositioning : 1
XResolution : 72.0
YResolution : 72.0
The problem is that critical data, that I need, is not in the list. For example focal length, metering mode, exposure time, and other metrics and details are not there, though I can see them by right clicking my image in the "Properties" section as the following image shows:
Why Pillow's TAGS can't read all the details. Is there any way to make it get all the details needed?
