There are cases where the GPS Altitude tag present in exif data is an Array instead of a number.
For example, running exiftool on the tests/data/gps-altitude.jpg image added in this PR returns:
GPS Altitude : 230 0 0 m
For such cases exifr crashes while parsing gps with a NoMethodError:
> exif = EXIFR::JPEG.new("tests/data/gps-altitude.jpg")
> exif.gps
NoMethodError: undefined method `to_f' for [(230/1), (0/1), (0/1)]:Array
Did you mean? to_s
to_a
to_h
This PR attempts to prevent exif.gps from crashing by using the first parameter of the Array as the gps_altitude value.
I'm not 100% sure if that's the correct approach as all cases I've seen so far have 0 0 a second and third parameters, so please advise in case there's a more precise approach.
There are cases where the
GPS Altitude
tag present in exif data is an Array instead of a number.For example, running
exiftool
on thetests/data/gps-altitude.jpg
image added in this PR returns:For such cases
exifr
crashes while parsinggps
with aNoMethodError
:This PR attempts to prevent
exif.gps
from crashing by using the first parameter of the Array as thegps_altitude
value.I'm not 100% sure if that's the correct approach as all cases I've seen so far have
0 0
a second and third parameters, so please advise in case there's a more precise approach.