Skip to content

Instantly share code, notes, and snippets.

@VioletVivirand
Last active August 26, 2025 08:57
Show Gist options
  • Save VioletVivirand/c62f58b756ac27e623614d09fc5ae6e1 to your computer and use it in GitHub Desktop.
Save VioletVivirand/c62f58b756ac27e623614d09fc5ae6e1 to your computer and use it in GitHub Desktop.
Extract EXIF from image in Python
from PIL import Image
with Image.open(image_path) as img:
img.load()
# #1 Read raw info
print(img.info)
print(img.info.keys())
print(img.info['exif'])
# #2 Use getexif() of _getexif()
from PIL import ExifTags
for key, val in img.getexif().items():
if key in ExifTags.TAGS:
print(f'{ExifTags.TAGS[key]}:{val}')
else:
print(f'{key}:{val}')
for key, val in img._getexif().items():
if key in ExifTags.TAGS:
print(f'{ExifTags.TAGS[key]}:{val}')
else:
print(f'{key}:{val}')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment