load image metadata with pil

Solutions on MaxInterview for load image metadata with pil by the best coders in the world

showing results for - "load image metadata with pil"
Aarón
31 Sep 2017
1import PIL.Image
2img = PIL.Image.open('img.jpg')
3exif_data = img._getexif()
4
5# iterating over all EXIF data fields
6for tag_id in exif_data:
7    # get the tag name, instead of human unreadable tag id
8    tag = TAGS.get(tag_id, tag_id)
9    data = exifdata.get(tag_id)
10    # decode bytes 
11    if isinstance(data, bytes):
12        data = data.decode()
13    print(f"{tag:25}: {data}")