Warning = Bad offset for GPS GPSLongitude problem

Started by Youngy, December 26, 2019, 06:50:04 PM

Previous topic - Next topic

Youngy

Hey, there seems to be an issue when decoding GPS information using rationals. I've done some digging and have been unable to find the cause of the error, but I'm getting the following command line output (I could just be doing something wrong with the command line arguments, but I read through the FAQ and tried a few different things and couldn't make any difference to it.

# exiftool -v4 e0_e1_test.jpg

" ExifToolVersion = 12.70
  FileName = e0_e1_test.jpg
  Directory = .
  FileSize = 1161
  FileModifyDate = 1577402080
  FileAccessDate = 1577402080
  FileInodeChangeDate = 1577402080
  FilePermissions = 33188
  FileType = JPEG
  FileTypeExtension = JPG
  MIMEType = image/jpeg
JPEG APP0 (14 bytes):
    0006: 4a 46 49 46 00 01 01 01 00 48 00 48 00 00       [JFIF.....H.H..]
  + [BinaryData directory, 9 bytes]
  | JFIFVersion = 1 1
  | - Tag 0x0000 (2 bytes, int8u[2]):
  |     000b: 01 01                                           [..]
  | ResolutionUnit = 1
  | - Tag 0x0002 (1 bytes, int8u[1]):
  |     000d: 01                                              [.]
  | XResolution = 72
  | - Tag 0x0003 (2 bytes, int16u[1]):
  |     000e: 00 48                                           [.H]
  | YResolution = 72
  | - Tag 0x0005 (2 bytes, int16u[1]):
  |     0010: 00 48                                           [.H]
  | ThumbnailWidth = 0
  | - Tag 0x0007 (1 bytes, int8u[1]):
  |     0012: 00                                              [.]
  | ThumbnailHeight = 0
  | - Tag 0x0008 (1 bytes, int8u[1]):
  |     0013: 00                                              [.]
JPEG APP1 (298 bytes):
    0018: 45 78 69 66 00 00 49 49 2a 00 08 00 00 00 06 00 [Exif..II*.......]
    0028: 1a 01 05 00 01 00 00 00 56 00 00 00 1b 01 05 00 [........V.......]
    0038: 01 00 00 00 5e 00 00 00 28 01 03 00 01 00 00 00 [....^...(.......]
    0048: 02 00 00 00 13 02 03 00 01 00 00 00 01 00 00 00 [................]
    0058: 69 87 04 00 01 00 00 00 66 00 00 00 25 88 04 00 [i.......f...%...]
    0068: 01 00 00 00 b4 00 00 00 00 00 00 00 48 00 00 00 [............H...]
    0078: 01 00 00 00 48 00 00 00 01 00 00 00 06 00 00 90 [....H...........]
    [snip 186 bytes]
  ExifByteOrder = II
  + [IFD0 directory with 6 entries]
  | 0)  XResolution = 72 (72/1)
  |     - Tag 0x011a (8 bytes, rational64u[1]):
  |         0074: 48 00 00 00 01 00 00 00                         [H.......]
  | 1)  YResolution = 72 (72/1)
  |     - Tag 0x011b (8 bytes, rational64u[1]):
  |         007c: 48 00 00 00 01 00 00 00                         [H.......]
  | 2)  ResolutionUnit = 2
  |     - Tag 0x0128 (2 bytes, int16u[1]):
  |         0048: 02 00                                           [..]
  | 3)  YCbCrPositioning = 1
  |     - Tag 0x0213 (2 bytes, int16u[1]):
  |         0054: 01 00                                           [..]
  | 4)  ExifOffset (SubDirectory) -->
  |     - Tag 0x8769 (4 bytes, int32u[1]):
  |         0060: 66 00 00 00                                     [f...]
  | + [ExifIFD directory with 6 entries]
  | | 0)  ExifVersion = 0210
  | |     - Tag 0x9000 (4 bytes, undef[4]):
  | |         008e: 30 32 31 30                                     [0210]
  | | 1)  ComponentsConfiguration = 1 2 3 0
  | |     - Tag 0x9101 (4 bytes, undef[4] read as int8u[4]):
  | |         009a: 01 02 03 00                                     [....]
  | | 2)  FlashpixVersion = 0100
  | |     - Tag 0xa000 (4 bytes, undef[4]):
  | |         00a6: 30 31 30 30                                     [0100]
  | | 3)  ColorSpace = 1
  | |     - Tag 0xa001 (2 bytes, int16u[1]):
  | |         00b2: 01 00                                           [..]
  | | 4)  ExifImageWidth = 64
  | |     - Tag 0xa002 (4 bytes, int32u[1]):
  | |         00be: 40 00 00 00                                     [@...]
  | | 5)  ExifImageHeight = 64
  | |     - Tag 0xa003 (4 bytes, int32u[1]):
  | |         00ca: 40 00 00 00                                     [@...]
  | 5)  GPSInfo (SubDirectory) -->
  |     - Tag 0x8825 (4 bytes, int32u[1]):
  |         006c: b4 00 00 00                                     [....]
  | + [GPS directory with 5 entries]
  | | 0)  GPSVersionID = 2 2 0 0
  | |     - Tag 0x0000 (4 bytes, int8u[4]):
  | |         00dc: 02 02 00 00                                     [....]
  | | 1)  GPSLatitudeRef = S
  | |     - Tag 0x0001 (2 bytes, string[2]):
  | |         00e8: 53 00                                           [S.]
  | | 2)  GPSLatitude = 37 48 48.941344 (37/1 48/1 48941344/1000000)
  | |     - Tag 0x0002 (24 bytes, rational64u[3]):
  | |         0114: 25 00 00 00 01 00 00 00 30 00 00 00 01 00 00 00 [%.......0.......]
  | |         0124: 20 c9 ea 02 40 42 0f 00                         [ ...@B..]
  | | 3)  GPSLongitudeRef = E
  | |     - Tag 0x0003 (2 bytes, string[2]):
  | |         0100: 45 00                                           [E.]
  | | Warning = Bad offset for GPS GPSLongitude
  | | 4)  GPSLongitude
  | |     - Tag 0x0004 (24 bytes, rational64u[3])
JPEG DQT (65 bytes):
    0148: 00 14 0e 0f 12 0f 0d 14 12 10 12 17 15 14 18 1e [................]
    0158: 32 21 1e 1c 1c 1e 3d 2c 2e 24 32 49 40 4c 4b 47 [2!....=,.$2I@LKG]
    0168: 40 46 45 50 5a 73 62 50 55 6d 56 45 46 64 88 65 [@FEPZsbPUmVEFd.e]
    0178: 6d 77 7b 81 82 81 4e 60 8d 97 8c 7d 96 73 7e 81 [mw{...N`...}.s~.]
    0188: 7c                                              [|]
JPEG SOF0 (9 bytes):
    018d: 08 00 40 00 40 01 01 11 00                      [..@.@....]
  ImageWidth = 64
  ImageHeight = 64
  EncodingProcess = 0
  BitsPerSample = 8
  ColorComponents = 1
JPEG DHT (25 bytes):
    019a: 00 00 03 01 01 01 01 01 00 00 00 00 00 00 00 00 [................]
    01aa: 00 00 05 06 04 03 07 02 01                      [.........]
JPEG DHT (45 bytes):
    01b7: 10 00 01 03 03 02 05 03 03 03 05 00 00 00 00 00 [................]
    01c7: 00 01 02 03 11 00 04 05 21 31 06 12 41 51 81 61 [........!1..AQ.a]
    01d7: 71 91 13 32 a1 14 22 c1 15 23 52 d1 f0          [q..2.."..#R..]
JPEG SOS
JPEG EOI"

I've manually stepped through the hex to find the data for the offending tag.

04 00 (GPS Longitude) 05 00 (Rational) 03 00 00 00 (3 of) 0e 01 00 00 (data offset)

This data offset, added to 0x1e (the offset to the start of the endianness bytes) gives 0x012c, and the next 24 bytes are the correct GPS Longitude data.

More Information

When I remove the GPS Longitude from the EXIF data, I get the same error, but for the GPS Latitude instead. Adding further fields continues to shift the Warning to new fields. I have seen GPS Timestamp, GPS Speed, GPS Track, GPS Image Direction and GPS Datestamp will all cause this error.

StarGeek

Someone else will have to look at the file in detail to see the problem, but it looks like the file can be fixed by using the command in FAQ #20.
"It didn't work" isn't helpful. What was the exact command used and the output.
Read FAQ #3 and use that cmd
Please use the Code button for exiftool output

Please include your OS/Exiftool version/filetype

Phil Harvey

The problem with the file you posted is that the APP1 segment length is 2 bytes too small.  It should be 0x1ea, but it is 0x1e8.

The segment size includes the 2-byte size word.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).