Skip to content

Instantly share code, notes, and snippets.

@twig
Created June 20, 2014 01:51
Python: IPTCInfo IPTC reader
# 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