Created
May 20, 2020 06:03
-
-
Save matts0613/d530b5bda892855ae9913ca5da040817 to your computer and use it in GitHub Desktop.
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
#requirement - pip3 install pillow | |
#Usage: python3 exif.py | |
#simple script that prints exif information for a user | |
#prompted image name in the same directory as this script | |
from PIL import Image | |
from PIL.ExifTags import TAGS | |
#prompt user for name of image | |
imagename = input("Enter name of the image: ") | |
# read the image data using PIL | |
image = Image.open(imagename) | |
# extract EXIF data | |
exifdata = image.getexif() | |
# iterating over all 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