exif

Making sense of EXIF longitude and latitude


If I right click the details on an image I get the following under GPS

enter image description here

When querying the EXIF (GpsLatitude and GpsLongitude) data I get

enter image description here

and

enter image description here

I can see that rows 0 and 8 are the degrees and minutes, but the rest makes no sense. What am I missing?

Thank you


Solution

  • Exif stores latitude and longitude as three rational numbers (fractions) where the numerator and denominator are four bytes long.

    In your example, you are only showing the first 14 values. There are 24 bytes of values to consider.

    Specifically, the latitude hours value is 0x00000027 / 0x00000001, or 39 / 1.

    Note that the values are stored little endian, so the bytes must be reversed.

    By only taking the bytes 0/8/16, you are potentially missing values that spill into the other bytes, and you're also assuming the denominator is always one.


    It's likely much easier to use a library to extract this information from your images. I maintain such a library for .NET which will work with VB.NET just fine, and has full support for Exif and many other kinds of metadata from many file formats.

    If you're interested, take a look at https://github.com/drewnoakes/metadata-extractor-dotnet