Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: skip empty EXIF values #557

Merged
merged 1 commit into from
Oct 4, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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