misc: ignore malformed exif data when geolocating from image (#47994)

This commit is contained in:
Frédéric Péters 2020-11-15 19:42:45 +01:00
parent 09a0f57883
commit 0aa4714e71
1 changed files with 7 additions and 2 deletions

View File

@ -203,8 +203,13 @@ class GeolocateWorkflowStatusItem(WorkflowStatusItem):
lon = (1.0 * lon[0] + 1.0 * lon[1]/60 + 1.0 * lon[2]/3600)
else:
# Pillow < 7.2 compat
lat = (1.0*lat[0][0]/lat[0][1] + 1.0*lat[1][0]/lat[1][1]/60 + 1.0*lat[2][0]/lat[2][1]/3600)
lon = (1.0*lon[0][0]/lon[0][1] + 1.0*lon[1][0]/lon[1][1]/60 + 1.0*lon[2][0]/lon[2][1]/3600)
try:
lat = (1.0*lat[0][0]/lat[0][1] + 1.0*lat[1][0]/lat[1][1]/60 + 1.0*lat[2][0]/lat[2][1]/3600)
lon = (1.0*lon[0][0]/lon[0][1] + 1.0*lon[1][0]/lon[1][1]/60 + 1.0*lon[2][0]/lon[2][1]/3600)
except ZeroDivisionError:
get_logger().debug('error geolocating from photo, invalid EXIF data (%r / %r)' % (
gps_info[2], gps_info[4]))
return
if lat_ref == 'S':
lat = -lat
if lon_ref == 'W':