When ExifString and ExifUndefined are four bytes or fewer, they are packed into the "offset" field. Since string and undefined are byte-oriented, they should appear in sequential order in the file and do not need to be byte-swapped. However, the ifdOffset field has already been byte-swapped. Therefore, for little-endian files, we need to swap ifdOffset back to undo the byte swapping.
A symptom was that ExifVersion was showing up as "0320", although there is no version 3.2 of EXIF, and exiftool shows the version correctly as "0230":
$ exif-test
Just (ExifUndefined "0320")
$ exiftool -ExifVersion test-image.jpg
Exif Version : 0230
After this fix, JuicyPixels correctly reports version "0230":
When
ExifString
andExifUndefined
are four bytes or fewer, they are packed into the "offset" field. Since string and undefined are byte-oriented, they should appear in sequential order in the file and do not need to be byte-swapped. However, theifdOffset
field has already been byte-swapped. Therefore, for little-endian files, we need to swapifdOffset
back to undo the byte swapping.A symptom was that ExifVersion was showing up as "0320", although there is no version 3.2 of EXIF, and exiftool shows the version correctly as "0230":
After this fix, JuicyPixels correctly reports version "0230":
Test program and image which demonstrate the problem: exif-test-version.zip