Fix #5524 Zero division error in exif.py
This patch implements the safe_gps_ratio_divide function for gps direction and altitude values to prevent a zero divide error on malformed GPS data.
This commit is contained in:
parent
763eae89d9
commit
07c535c876
@ -175,18 +175,14 @@ def get_gps_data(tags):
|
||||
pass
|
||||
|
||||
try:
|
||||
gps_data['direction'] = (
|
||||
lambda d:
|
||||
float(d.num) / float(d.den)
|
||||
)(tags['GPS GPSImgDirection'].values[0])
|
||||
direction = tags['GPS GPSImgDirection'].values[0]
|
||||
gps_data['direction'] = safe_gps_ratio_divide(direction)
|
||||
except KeyError:
|
||||
pass
|
||||
|
||||
try:
|
||||
gps_data['altitude'] = (
|
||||
lambda a:
|
||||
float(a.num) / float(a.den)
|
||||
)(tags['GPS GPSAltitude'].values[0])
|
||||
altitude = tags['GPS GPSAltitude'].values[0]
|
||||
gps_data['altitude'] = safe_gps_ratio_divide(altitude)
|
||||
except KeyError:
|
||||
pass
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user