Skip to content

Commit

Permalink
fix: skip empty EXIF values (#557)
Browse files Browse the repository at this point in the history
  • Loading branch information
Tao Peng authored Oct 4, 2022
1 parent 47d94a9 commit 45aa8cb
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions mapillary_tools/exif_read.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,15 +99,18 @@ def _extract_alternative_fields(
"""
for field in fields:
if field in self.tags:
values = self.tags[field].values
if field_type is float:
try:
return eval_frac(self.tags[field].values[0]), field
except ZeroDivisionError:
pass
if values:
try:
return eval_frac(values[0]), field
except ZeroDivisionError:
pass
elif field_type is str:
return str(self.tags[field].values), field
return str(values), field
elif field_type is int:
return int(self.tags[field].values[0]), field
if values:
return int(values[0]), field
else:
raise ValueError(f"Invalid field type {field_type}")
return default, None
Expand Down

0 comments on commit 45aa8cb

Please sign in to comment.