How to how gps coordinates are encoded in exif data
- Step 1Locate the GPS IFD — EXIF stores GPS data in a sub-IFD pointed to by tag 0x8825 in IFD0. Navigate the IFD linked list from the TIFF header to find it.
- Step 2Read the latitude rational triplet — Tag 0x0002 (GPSLatitude) holds three RATIONAL values (each a 64-bit numerator/denominator pair). Compute decimal = degrees + minutes/60 + seconds/3600.
- Step 3Apply hemisphere reference — Tag 0x0001 (GPSLatitudeRef) is 'N' or 'S'. Multiply by -1 for south. Tag 0x0003/0x0004 apply the same logic for longitude with 'E'/'W'.
Frequently asked questions
What is the RATIONAL data type in EXIF?+
Two consecutive uint32 values: numerator then denominator. Each takes 4 bytes, so a full DMS triplet occupies 24 bytes. Values are always positive; direction is encoded in the Ref tags.
How is altitude stored?+
Tag 0x0006 (GPSAltitude) is a single RATIONAL value in metres. Tag 0x0005 (GPSAltitudeRef) is 0 for above sea level, 1 for below. Many cameras omit altitude entirely.
Which JavaScript library handles EXIF GPS reliably?+
piexifjs is the most widely used pure-JS library for EXIF parsing and writing. exifr is a more modern alternative with async streaming support and broader format coverage including HEIC.
Privacy first
Every JAD Security operation runs entirely in your browser. Files, passwords, and PGP private keys never leave your device — verified by zero outbound network requests during processing.