Main Menu

Changes in tags order

Started by banana123, January 02, 2025, 04:15:15 PM

Previous topic - Next topic

banana123

While working on embedding some thumbnails to a batch of images, I noticed that in some cases, the order of the EXIF tags changes after the embedding process. the changes are in order/location only (tags & values are keep the same), and it happens with tags that are not even looks like related to the thumbnail. the changes are in tags that are before the thumbnail...
This only happens in part of the images and I can't identify a consistent pattern in which ones do and which don't.
Is this supposed to happen?
What causes this?

StarGeek

See FAQ #13

You might also run this command on the file to see if the EXIF data was structured properly in the first place
exiftool -g1 -a -s -warning -validate file.jpg

There are a lot of cameras that will incorrectly write EXIF data, as well as writing large blocks of unused data as mentioned in the FAQ. Plus, depending upon the command, exiftool might be adding tags which the EXIF standard considers "Mandatory".

After running the validate command, you can ignore the warnings that pop up about mandatory tags. Here's an example of a messy one
C:\>exiftool -g1 -a -s -warning -validate Y:\!temp\!Metadata_Repository\DJI\DJI_FC6310.jpg
---- ExifTool ----
Warning                         : [minor] Odd offset for IFD0 tag 0x010f Make
Warning                         : [minor] Odd offset for IFD0 tag 0x0110 Model
Warning                         : [minor] Odd offset for IFD0 tag 0x011a XResolution
Warning                         : [minor] Odd offset for IFD0 tag 0x011b YResolution
Warning                         : [minor] Odd offset for IFD0 tag 0x0131 Software
Warning                         : [minor] Odd offset for IFD0 tag 0x0132 ModifyDate
Warning                         : [minor] Odd offset for ExifIFD tag 0x829a ExposureTime
Warning                         : [minor] Odd offset for ExifIFD tag 0x829d FNumber
Warning                         : [minor] Odd offset for ExifIFD tag 0x9003 DateTimeOriginal
Warning                         : [minor] Odd offset for ExifIFD tag 0x9004 CreateDate
Warning                         : [minor] Odd offset for ExifIFD tag 0x9102 CompressedBitsPerPixel
Warning                         : [minor] Odd offset for ExifIFD tag 0x9201 ShutterSpeedValue
Warning                         : [minor] Odd offset for ExifIFD tag 0x9202 ApertureValue
Warning                         : [minor] Odd offset for ExifIFD tag 0x9204 ExposureCompensation
Warning                         : [minor] Odd offset for ExifIFD tag 0x9205 MaxApertureValue
Warning                         : [minor] Odd offset for ExifIFD tag 0x9206 SubjectDistance
Warning                         : [minor] Odd offset for ExifIFD tag 0x920a FocalLength
Warning                         : [minor] Odd offset for ExifIFD tag 0x927c
Warning                         : [minor] Possibly incorrect maker notes offsets (fix by 1783?)
Warning                         : [minor] Odd offset for ExifIFD tag 0xa215 ExposureIndex
Warning                         : [minor] Undefined value for ExifIFD:ExposureIndex
Warning                         : [minor] Odd offset for ExifIFD tag 0xa404 DigitalZoomRatio
Warning                         : [minor] Undefined value for ExifIFD:DigitalZoomRatio
Warning                         : [minor] Odd offset for ExifIFD tag 0xa431 SerialNumber
Warning                         : [minor] Odd offset for GPS tag 0x0002 GPSLatitude
Warning                         : [minor] Odd offset for GPS tag 0x0004 GPSLongitude
Warning                         : [minor] Odd offset for GPS tag 0x0006 GPSAltitude
Warning                         : [minor] Odd offset for IFD0 tag 0x9c9c XPComment
Warning                         : [minor] Odd offset for IFD0 tag 0x9c9e XPKeywords
Warning                         : [minor] Odd offset for IFD1 tag 0x011a XResolution
Warning                         : [minor] Odd offset for IFD1 tag 0x011b YResolution
Validate                        : 31 Warnings (all minor)

Usually, these aren't too much to worry about. Most programs will still be able to read the data.
"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

banana123

Quote from: StarGeek on January 02, 2025, 07:58:03 PMSee FAQ #13

You might also run this command on the file to see if the EXIF data was structured properly in the first place
exiftool -g1 -a -s -warning -validate file.jpg

There are a lot of cameras that will incorrectly write EXIF data, as well as writing large blocks of unused data as mentioned in the FAQ. Plus, depending upon the command, exiftool might be adding tags which the EXIF standard considers "Mandatory".

After running the validate command, you can ignore the warnings that pop up about mandatory tags. Here's an example of a messy one
C:\>exiftool -g1 -a -s -warning -validate Y:\!temp\!Metadata_Repository\DJI\DJI_FC6310.jpg
---- ExifTool ----
Warning                         : [minor] Odd offset for IFD0 tag 0x010f Make
Warning                         : [minor] Odd offset for IFD0 tag 0x0110 Model
Warning                         : [minor] Odd offset for IFD0 tag 0x011a XResolution
Warning                         : [minor] Odd offset for IFD0 tag 0x011b YResolution
Warning                         : [minor] Odd offset for IFD0 tag 0x0131 Software
Warning                         : [minor] Odd offset for IFD0 tag 0x0132 ModifyDate
Warning                         : [minor] Odd offset for ExifIFD tag 0x829a ExposureTime
Warning                         : [minor] Odd offset for ExifIFD tag 0x829d FNumber
Warning                         : [minor] Odd offset for ExifIFD tag 0x9003 DateTimeOriginal
Warning                         : [minor] Odd offset for ExifIFD tag 0x9004 CreateDate
Warning                         : [minor] Odd offset for ExifIFD tag 0x9102 CompressedBitsPerPixel
Warning                         : [minor] Odd offset for ExifIFD tag 0x9201 ShutterSpeedValue
Warning                         : [minor] Odd offset for ExifIFD tag 0x9202 ApertureValue
Warning                         : [minor] Odd offset for ExifIFD tag 0x9204 ExposureCompensation
Warning                         : [minor] Odd offset for ExifIFD tag 0x9205 MaxApertureValue
Warning                         : [minor] Odd offset for ExifIFD tag 0x9206 SubjectDistance
Warning                         : [minor] Odd offset for ExifIFD tag 0x920a FocalLength
Warning                         : [minor] Odd offset for ExifIFD tag 0x927c
Warning                         : [minor] Possibly incorrect maker notes offsets (fix by 1783?)
Warning                         : [minor] Odd offset for ExifIFD tag 0xa215 ExposureIndex
Warning                         : [minor] Undefined value for ExifIFD:ExposureIndex
Warning                         : [minor] Odd offset for ExifIFD tag 0xa404 DigitalZoomRatio
Warning                         : [minor] Undefined value for ExifIFD:DigitalZoomRatio
Warning                         : [minor] Odd offset for ExifIFD tag 0xa431 SerialNumber
Warning                         : [minor] Odd offset for GPS tag 0x0002 GPSLatitude
Warning                         : [minor] Odd offset for GPS tag 0x0004 GPSLongitude
Warning                         : [minor] Odd offset for GPS tag 0x0006 GPSAltitude
Warning                         : [minor] Odd offset for IFD0 tag 0x9c9c XPComment
Warning                         : [minor] Odd offset for IFD0 tag 0x9c9e XPKeywords
Warning                         : [minor] Odd offset for IFD1 tag 0x011a XResolution
Warning                         : [minor] Odd offset for IFD1 tag 0x011b YResolution
Validate                        : 31 Warnings (all minor)

Usually, these aren't too much to worry about. Most programs will still be able to read the data.

Thanks for your answer.
Actually, I'm not having a problem of extra tags or unused data. All of the data is OK, same tags and same values - just a different tags order in the EXIF segment.
Does EXIF specification are define a specific order of tags? if so - can you give me some reference to dive into it?
Another question from your example - what are the logics of defining a warning? what makes an offset "odd" or not?

Phil Harvey

According to the TIFF specification:  Tags in a TIFF/EXIF IFD must be in order of increasing  tag ID number.  Values must be on even word boundaries, so all offsets must be even numbers.

- 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 ($).

banana123

Quote from: Phil Harvey on January 03, 2025, 01:35:46 PMAccording to the TIFF specification:  Tags in a TIFF/EXIF IFD must be in order of increasing  tag ID number.  Values must be on even word boundaries, so all offsets must be even numbers.

- Phil

Ohh thank! I didn't knew that detail.
So in images where the EXIF data was not structured properly in the first place (tags are not in increasing ID number), does exiftool will order them in every "writing data" command?

Phil Harvey

If you write EXIF then ExifTool will fix both the ordering and the odd-offset problems.

- 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 ($).

banana123

Quote from: Phil Harvey on January 03, 2025, 02:43:13 PMIf you write EXIF then ExifTool will fix both the ordering and the odd-offset problems.

- Phil

It's good to know.. I was struggling with this for a while..
Is there any flag that can disable those fixes?
How does the odd-offset fix is happening? (which steps are exiftool do for fixing this kind of problem)

StarGeek

Quote from: banana123 on January 03, 2025, 01:17:51 PMActually, I'm not having a problem of extra tags or unused data. All of the data is OK, same tags and same values - just a different tags order in the EXIF segment.

I couldn't find a file with that exact problem quickly, so I used what I could find. But on such a file as you describe, the validate command would probably return something like EXIF tags out of order. And probably other warnings as well.

QuoteDoes EXIF specification are define a specific order of tags? if so - can you give me some reference to dive into it?

The EXIF standard can be downloaded here.

On page 28 (PDF page 39), it says
QuoteNote that field entry shall be recorded in sequence starting from the smallest tag number.
"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

Quote from: banana123 on January 03, 2025, 03:18:35 PMIs there any flag that can disable those fixes?

No.

QuoteHow does the odd-offset fix is happening? (which steps are exiftool do for fixing this kind of problem)

When ExifTool writes the EXIF, it adds a padding byte after an odd-sized value.

- 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 ($).