Skip to content

Instantly share code, notes, and snippets.

@XSAM
Last active July 17, 2021 10:52
Show Gist options
  • Save XSAM/cff5e4de0caea8d9eef172c8a1eaae4f to your computer and use it in GitHub Desktop.
Save XSAM/cff5e4de0caea8d9eef172c8a1eaae4f to your computer and use it in GitHub Desktop.
Py image
from PIL import Image
from PIL.ExifTags import TAGS
# read the image data using PIL
# A image that should be read.
# 300*200
image = Image.open("sample.png")
exifdata = image.getexif()
# Move iterator.
# Virtual memory won't impact this.
# 600 pixels.
# RAW 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}")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment