Merge pull request #355 from tudacs/master
Fixes sigal aborting if image contains malformed metadata
This commit is contained in:
@@ -235,11 +235,22 @@ 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)
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
iptc_data = {}
|
||||
raw_iptc = {}
|
||||
|
||||
# PILs IptcImagePlugin issues a SyntaxError in certain circumstances
|
||||
# with malformed metadata, see PIL/IptcImagePlugin.py", line 71.
|
||||
# ( https://github.com/python-pillow/Pillow/blob/9dd0348be2751beb2c617e32ff9985aa2f92ae5f/src/PIL/IptcImagePlugin.py#L71 )
|
||||
try:
|
||||
img = _read_image(filename)
|
||||
raw_iptc = IptcImagePlugin.getiptcinfo(img)
|
||||
except SyntaxError:
|
||||
logger.info('IPTC Error in %s',filename)
|
||||
|
||||
# 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')
|
||||
|
||||
Reference in New Issue
Block a user