|
|
|
|
@ -235,18 +235,23 @@ def get_exif_data(filename):
|
|
|
|
|
def get_iptc_data(filename): |
|
|
|
|
"""Return a dict with the raw IPTC data.""" |
|
|
|
|
|
|
|
|
|
img = _read_image(filename) |
|
|
|
|
raw_iptc = IptcImagePlugin.getiptcinfo(img) |
|
|
|
|
# IPTC fields are catalogued in: |
|
|
|
|
# https://www.iptc.org/std/photometadata/specification/IPTC-PhotoMetadata |
|
|
|
|
iptc_data = {} |
|
|
|
|
# 2:05 is the IPTC title property |
|
|
|
|
if raw_iptc and (2, 5) in raw_iptc: |
|
|
|
|
iptc_data["title"] = raw_iptc[(2, 5)].decode('utf-8') |
|
|
|
|
|
|
|
|
|
# 2:120 is the IPTC description property |
|
|
|
|
if raw_iptc and (2, 120) in raw_iptc: |
|
|
|
|
iptc_data["description"] = raw_iptc[(2, 120)].decode('utf-8') |
|
|
|
|
try: |
|
|
|
|
img = _read_image(filename) |
|
|
|
|
raw_iptc = IptcImagePlugin.getiptcinfo(img) |
|
|
|
|
# IPTC fields are catalogued in: |
|
|
|
|
# https://www.iptc.org/std/photometadata/specification/IPTC-PhotoMetadata |
|
|
|
|
# 2:05 is the IPTC title property |
|
|
|
|
if raw_iptc and (2, 5) in raw_iptc: |
|
|
|
|
iptc_data["title"] = raw_iptc[(2, 5)].decode('utf-8') |
|
|
|
|
|
|
|
|
|
# 2:120 is the IPTC description property |
|
|
|
|
if raw_iptc and (2, 120) in raw_iptc: |
|
|
|
|
iptc_data["description"] = raw_iptc[(2, 120)].decode('utf-8') |
|
|
|
|
except SyntaxError: |
|
|
|
|
print("IPTC Error in %s\n"%filename) |
|
|
|
|
iptc_data = {} |
|
|
|
|
|
|
|
|
|
return iptc_data |
|
|
|
|
|
|
|
|
|
|