2

I am trying to extract GPS metadata from hex following this tutorial, but cannot understand why at the end the latitude and longitude have length 24 and values 42 and 73: http://itbrigadeinc.com/post/2012/03/06/Anatomy-of-a-JPG-image.aspx http://www.itbrigadeinc.com/post/2012/03/16/Seeing-the-EXIF-data-for-a-JPG-image.aspx

I found the tags of latitude and longitude (00 02 00 05 00 00 00 03 00 00 02 42) and (00 04 00 05 00 00 00 03 00 00 02 5A). As I understood, if count = 3, then the values of both of them should follow in the last 4 bytes of tags. but 02 42 and 02 5A are not "42" and "73"...

Who could explain me what is wrong?

Please, don't recommend any tools - I need to do it manually.

Himeiji
  • 21
  • 3

2 Answers2

1

You need to also consider the size of each value. The count is three, but the size of each is larger than one byte. Therefore it won't fit in the four bytes, and those four bytes represent an offset to the value.

GPS data is usually stored as three rational numbers, where each rational number is two 32-bit integers (numerator, denominator). Therefore you have three values for latitude, but each is 8 bytes. The 24 bytes won't fit within the TIFF tag, so it is stored somewhere else in the file, and the four bytes you're seeing are a pointer to it. You need to look into the spec to find out where that pointer is relative to, as it's probably not the start of the file.

Check out my metadata extractor libraries (in Java and C#) for reference.

Drew Noakes
  • 300,895
  • 165
  • 679
  • 742
0

Apparently the 24 bit data type is a PropertyTagTypeRational https://msdn.microsoft.com/en-us/library/ms534414(v=vs.85).aspx

Specifies that the value data member is an array of pairs of unsigned long integers. Each pair represents a fraction; the first integer is the numerator and the second integer is the denominator.

Mostly gotten from: Getting GPS data from an image's EXIF in C#

This bit of python code might have a good hint too at how you can decode the data http://eran.sandler.co.il/2011/05/20/extract-gps-latitude-and-longitude-data-from-exif-using-python-imaging-library-pil/

Community
  • 1
  • 1
the JinX
  • 1,950
  • 1
  • 18
  • 23