Author Topic: -tagsfromfile adds XMP:GPSDateTime  (Read 934 times)

johnrellis

  • Full Member
  • ***
  • Posts: 60
-tagsfromfile adds XMP:GPSDateTime
« on: July 06, 2019, 04:01:04 PM »
"-tagsfromfile from.jpg" adds XMP:GPSDateTime even when "from.jpg" doesn't contain any XMP fields:

Code: [Select]
$ exiftool -a -G1 from.jpg | grep -i gps
[GPS]           GPS Version ID                  : 2.2.0.0
[GPS]           GPS Latitude Ref                : North
[GPS]           GPS Latitude                    : 43 deg 46' 23.63"
[GPS]           GPS Longitude Ref               : East
[GPS]           GPS Longitude                   : 11 deg 15' 41.32"
[GPS]           GPS Time Stamp                  : 21:21:27.74
[GPS]           GPS Speed Ref                   : km/h
[GPS]           GPS Speed                       : 0
[GPS]           GPS Img Direction Ref           : True North
[GPS]           GPS Img Direction               : 71.06683805
[GPS]           GPS Dest Bearing Ref            : True North
[GPS]           GPS Dest Bearing                : 71.06683805
[GPS]           GPS Date Stamp                  : 2018:06:19
[GPS]           GPS Horizontal Positioning Error: 2000 m
[Composite]     GPS Date/Time                   : 2018:06:19 21:21:27.74Z
[Composite]     GPS Latitude                    : 43 deg 46' 23.63" N
[Composite]     GPS Longitude                   : 11 deg 15' 41.32" E
[Composite]     GPS Position                    : 43 deg 46' 23.63" N, 11 deg 15' 41.32" E

$ exiftool -xmp:all= -gps:all= to.jpg
    1 image files updated

$ exiftool -tagsfromfile from.jpg to.jpg
    1 image files updated

$ exiftool -a -G1 to.jpg | grep -i gps
[GPS]           GPS Version ID                  : 2.2.0.0
[GPS]           GPS Latitude Ref                : North
[GPS]           GPS Latitude                    : 43 deg 46' 23.63"
[GPS]           GPS Longitude Ref               : East
[GPS]           GPS Longitude                   : 11 deg 15' 41.32"
[GPS]           GPS Time Stamp                  : 21:21:27.74
[GPS]           GPS Speed Ref                   : km/h
[GPS]           GPS Speed                       : 0
[GPS]           GPS Img Direction Ref           : True North
[GPS]           GPS Img Direction               : 71.06683805
[GPS]           GPS Dest Bearing Ref            : True North
[GPS]           GPS Dest Bearing                : 71.06683805
[GPS]           GPS Date Stamp                  : 2018:06:19
[GPS]           GPS Horizontal Positioning Error: 2000 m
[XMP-exif]      GPS Date/Time                   : 2018:06:19 21:21:27.74Z
[Composite]     GPS Date/Time                   : 2018:06:19 21:21:27.74Z
[Composite]     GPS Latitude                    : 43 deg 46' 23.63" N
[Composite]     GPS Longitude                   : 11 deg 15' 41.32" E
[Composite]     GPS Position                    : 43 deg 46' 23.63" N, 11 deg 15' 41.32" E

$ exiftool -ver
11.54


StarGeek

  • Global Moderator
  • ExifTool Freak
  • *****
  • Posts: 3969
Re: -tagsfromfile adds XMP:GPSDateTime
« Reply #1 on: July 06, 2019, 04:39:00 PM »
Yes. Composite:GPSDateTime is being copied to the preferred (and only?) location of XMP:GPSDateTime

As per the -TagsFromFile option docs
If no tags are specified, then all possible tags (see note 1 below) from the source file are copied to same-named tags in the preferred location of the output file (the same as specifying -all).

If you want to copy tags to the same exact location, you need to specify -all:all
For example, the common operation of copying all writable tags to the same specific locations in the output FILE is achieved by adding -all:all.

If you only had XMP GPS tags in a file and used that command, then the gps tags would be copied to the GPS group and the to file would only have GPS tags, not XMP GPS tags (except for GPSDateTime).  Also, there wouldn't be any Ref tags.
Troubleshooting hints:
* When posting, include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).
* Double all percent signs (%) in a Windows batch file.
* If your GPS coords are negative, make sure and set the GpsLatitudeRef and GpsLongitudeRef tags correctly.

johnrellis

  • Full Member
  • ***
  • Posts: 60
Re: -tagsfromfile adds XMP:GPSDateTime
« Reply #2 on: July 06, 2019, 06:11:49 PM »
Why does Composite:GPSDateTime have a preferred location in XMP-exif, while Composite:Latitude doesn't have a preferred location in XMP-exif? Ditto for Longitude.

Put another way, why do GPS:GPSDateStamp/GPSTimeStamp get copied to both GPS and XMP-exif, while GPS:Latitude/LatitudeRef only get copied to GPS? 

StarGeek

  • Global Moderator
  • ExifTool Freak
  • *****
  • Posts: 3969
Re: -tagsfromfile adds XMP:GPSDateTime
« Reply #3 on: July 06, 2019, 07:18:29 PM »
The GPS group is part of the EXIF group (see GPS Tags).
These GPS tags are part of the EXIF standard, and are stored in a separate IFD within the EXIF information.

As per the -TAG option
The preferred group is the first group in the following list where TAG is valid: 1) EXIF, 2) IPTC, 3) XMP.

That's why GPSLatitude/GPSLongitude, from any source, will get copied to GPS:GPSLatitude/GPS:GPSLongitude, aka EXIF:GPSLatitude/EXIF:GPSLongitude.

Quote
Put another way, why do GPS:GPSDateStamp/GPSTimeStamp get copied to both GPS and XMP-exif, while GPS:Latitude/LatitudeRef only get copied to GPS?

GPSDateStamp and GPSTimeStamp only get copied to the same named tags in the preferred group, which happen to be GPS:GPSDateStamp and GPS:GPSTimeStamp.  They do not get copied to XMP:GPSDateTime.  But since Composite:GPSDateTime exists, the value of GPSDateTime gets copied to the same name tag in the preferred group, which would be XMP:GPSDateTime

All of this assumes you don't name any specific tags or groups using -TagsFromFile, which is the same as -All (not the same as -All:All).

Troubleshooting hints:
* When posting, include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).
* Double all percent signs (%) in a Windows batch file.
* If your GPS coords are negative, make sure and set the GpsLatitudeRef and GpsLongitudeRef tags correctly.

johnrellis

  • Full Member
  • ***
  • Posts: 60
Re: -tagsfromfile adds XMP:GPSDateTime
« Reply #4 on: July 06, 2019, 08:44:14 PM »
Thanks.  I was aware of the concept of preferred groups for -tagsfromfile but not the detailed rule that's specified elsewhere in the man page. 

It's an unfortunate interaction between that simple rule and the name of one particular Composite tag.  Composite:GPSLatitude has the same tag name as EXIF:GPSLatitude, so it doesn't add an XMP field, while Composite:GPSDateTime doesn't have the same tag name as an EXIF field, so it adds an XMP field.

The original use case involved source and destinations of potentially different file formats, which is why -tagsfromfile was used (as suggested by the man page) without -all:all. It's another example of where copying GPS fields from one format to another has to be format-aware: https://exiftool.org/forum/index.php/topic,8401.msg43191.html#msg43191.

I tried to think of a feature request that would simplify this without renaming Composite:GPSDateTime but failed.

Phil Harvey

  • ExifTool Author
  • Administrator
  • ExifTool Freak
  • *****
  • Posts: 16885
    • ExifTool Home Page
Re: -tagsfromfile adds XMP:GPSDateTime
« Reply #5 on: July 08, 2019, 08:34:49 AM »
It is unfortunate that asymmetries like this exist, but the root cause is the difference between the GPS tag definitions for EXIF and XMP.  This is also the reason why there are argument files included in the full distribution to handle the details of converting between these.  The bottom line is that sometimes you do need to tweak ExifTool's default behaviour to get the results you want when copying tags.

In this particular case, I could maybe improve the situation by making Composite:GPSDateTime writable, but I haven't read through this entire thread so I'm not sure this would help.  Also, I would have to think hard about possible side-effects of making a change like this because it may affect other people's workflows.

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

johnrellis

  • Full Member
  • ***
  • Posts: 60
Re: -tagsfromfile adds XMP:GPSDateTime
« Reply #6 on: July 08, 2019, 11:57:32 AM »
Thanks much.  For my programmatic use of ExifTool, I learned a long time ago that copying tags between formats, especially GPS, had to be format-aware.  But I had to relearn that lesson once again. My proposal for orthogonal composite GPS tags would ameliorate the situation but hardly solve it, and it wouldn't have addressed this use-case.