mattiasw / ExifReader

A JavaScript Exif info parser.
Mozilla Public License 2.0
743 stars 89 forks source link

exif-reader.d.ts's NumberArrayTag type for GPSLatitude & GPSLongitude should be number[][] rather than number[] #288

Closed alee8 closed 6 days ago

alee8 commented 5 months ago

Description

Exif's GPSLatitude & GPSLongitude type definition should be number[][] rather than number[].

getCalculatedGpsValue expects each of its first 3 function parameters (degrees, minutes, seconds) to be a number[]. Each parameter is based on value[0], value[1], and value[2] of GPSLatitude & GPSLongitude. Thus the value prop has a type of number[][].

Additional details

How to reproduce

  1. Read the tags from an Android photo using the example site's ES module
  2. Take the tags' GPSLatitude/GPSLongitude and pass it to a typescripted function akin to getCalculatedGpsValue such as gpsDMSToFloat(latLng: NumberArrayTag, latLngRef: StringArrayTag)

     function gpsDMSToFloat(latLng: NumberArrayTag, latLngRef: StringArrayTag) {
        const latLngDeg = latLng.value[0];
        const latLngMin = latLng.value[1];
        const latLngSec = llatLng.value[2];
        return (latLngDeg[0] / latLngDeg[1]) + (latLngMin[0] / latLngMin[1]) / 60 + (latLngSec[0] / latLngSec[1]) / 3600;
     }
  3. Typescript error regarding latLngDeg, latLngMin, latLngSec

What I expected would happen:

No typescript error associated with accessing value of GPSLatitude/GPSLongitude in the manner shown above.

What really happened:

Typescript error regarding latLngDeg, latLngMin, latLngSec

Example JPEG image

PXL_20240221_210408399 NIGHT

mattiasw commented 5 months ago

Hi! Thanks for the report. I will have a look.

mattiasw commented 6 days ago

Fix published as version 4.23.5.