Last active
July 17, 2021 10:52
-
-
Save XSAM/cff5e4de0caea8d9eef172c8a1eaae4f to your computer and use it in GitHub Desktop.
Py image
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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