/python-iptcinfo-iptic-reader.py Secret
Created
June 20, 2014 01:51
Python: IPTCInfo IPTC reader
This file contains hidden or 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
# pip install iptcinfo | |
import iptcinfo | |
im = Image.open(filename) | |
im.verify() | |
# Not sure what other formats are supported, I never looked into it. | |
if im.format in ['JPG', 'TIFF']: | |
try: | |
iptc = iptcinfo.IPTCInfo(filename) | |
image_title = iptc.data.get('object name', '') or iptc.data.get('headline', '') | |
image_description = iptc.data.get('caption/abstract', '') | |
image_tags = iptc.keywords | |
except Exception, e: | |
if str(e) != "No IPTC data found.": | |
raise |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment