I'm trying to get all image metadata using PIL Exif.There is a great snippet kinda has to work well but
from PIL import Image
from PIL.ExifTags import TAGS
def get_exif(fn):
ret = {}
i = Image.open(fn)
i.load()
info = i._getexif()
print(info)
for tag, value in info.items():
decoded = TAGS.get(tag, tag)
ret[decoded] = value
return ret
get_exif(img_path)
error without i.load()
AttributeError: 'NoneType' object has no attribute 'items'
Image exists, "i" variable shows image. I tried different images but the same output happens. Firstly, I found here Python Image Library - Make area of image transparent that error can be related to the fact that Image.open is lazy, so I added Image.load(). But it didn't help. May someone explain behaviour of the error and what should I try else to get the dictionary object of all image metadata?