Rounding Issues between XMP-exif and native GPS?

Started by Mac2, March 30, 2024, 11:27:37 AM

Previous topic - Next topic

Mac2

As part of a larger args file, my software writes

-XMP-exif:GPSImgDirection#=321.694417
and at the end it runs XMP2*.args files provided by ExifTool to map XMP data back into native GPS data, IPTC and EXIF data as needed.
When I look at the resulting data in the image, I get the following values for the GPSImgDirection tag:

[GPS]          GPS Img Direction              : 321.6944172
[XMP-exif]     GPS Img Direction              : 321.694417238002

I would have expected that all values match the value I've written. Or at least are identical.
I know this is floating point math and rounding comes into play, but I wonder if there is something I can do to improve this?

Results like this cause issues when I compare metadata in files with the tag values I have cached in a database.
I can allow for a certain difference of course when performing comparisons, but maybe I do something wrong when writing the data.

Ps.: I get the same result when I write the tag as text, as in

-XMP-exif:GPSImgDirection=321.694417

Phil Harvey

The EXIF GPS value is rounded to 10 significant digits, which is about the limit of precision since it is stored as two 32-bit integers.  The XMP value is also stored as 2 integers, but is not limited to 32 bits (in theory), so it is not rounded.

But regardless, there will always be some rounding due to the rational representation.

For GPSImgDirection, the precision is about 6 significant figures more than is necessary.  I think it makes sense for you to loosen your tolerance on matching the database.

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

wywh

At least that value seems to be stored internally as 328450/1021 in both GPS and XMP-exif groups (with -v3, you can see the precision):

exiftool -overwrite_original -XMP-exif:GPSImgDirection=321.694417 -GPS:GPSImgDirection=321.694417 image.jpg

exiftool -a -G1 -s -GPSImgDirection image.jpg                                                             
[GPS]           GPSImgDirection                 : 321.6944172
[XMP-exif]      GPSImgDirection                 : 321.694417238002

exiftool -a -G1 -s -GPSImgDirection -v3 image.jpg
  | + [GPS directory with 2 entries]
  | | 1)  GPSImgDirection = 321.6944172 (328450/1021)
  + [XMP directory, 2813 bytes]
  | GPSImgDirection = 328450/1021

- Matti

Mac2

Thanks, Phil

This explains my findings.
I have made changes to allow for some variation in rounding for these tags instead of doing a simple written == read ? comparison. It affects only a handful of numeric tags in my case anyway.