ExifTool Forum

General => Metadata => Topic started by: wywh on December 28, 2020, 01:51:49 PM

Title: Photos.app .xmp date to .jpg
Post by: wywh on December 28, 2020, 01:51:49 PM
How can I add the following sidecar .xmp to a .jpg so that also the date is correctly added?

Photos.app 6.0 (macOS 11 Big Sur) command "Export Unmodified Original, Export IPTC as XMP" exports the following sidecar .xmp:

exiftool -a -G1 -s a.xmp
[ExifTool]      ExifToolVersion                 : 12.00
[XMP-x]         XMPToolkit                      : XMP Core 6.0.0
[XMP-exif]      GPSLongitude                    : 0 deg 7' 34.45" E
[XMP-exif]      GPSLongitudeRef                 : W
[XMP-exif]      GPSHPositioningError            : 1 m
[XMP-exif]      GPSLatitude                     : 51 deg 30' 0.55" N
[XMP-exif]      GPSLatitudeRef                  : N
[XMP-exif]      GPSDateTime                     : 2020:12:28 17:33:10Z
[XMP-dc]        Title                           : Title text.
[XMP-dc]        Description                     : Caption text.
[XMP-dc]        Subject                         : Keyword 1, Keyword 2
[XMP-photoshop] DateCreated                     : 2010:07:01 12:00:00+03:00


When adding .xmp to the .jpg, the following kinda works and Photos.app re-imports other tags OK. But it does not update an existing or populate an empty ExifIFD:DateTimeOriginal tag (neither do -xmp:all or '-all:all<xmp:all' or -xmp):

exiftool -m -P -overwrite_original_in_place -ext jpg -tagsfromfile %d%f.xmp -all:all .

Adding that XMP-photoshop:DateCreated fixes the problem but is there a more elegant solution?

exiftool -m -P -overwrite_original_in_place -ext jpg -tagsfromfile %d%f.xmp -all:all '-ExifIFD:DateTimeOriginal<XMP-photoshop:DateCreated' .

- Matti
Title: Re: Photos.app .xmp date to .jpg
Post by: Phil Harvey on December 28, 2020, 02:04:31 PM
You could populate all EXIF tags using this arg file (https://raw.githubusercontent.com/exiftool/exiftool/master/arg_files/xmp2exif.args).

This should solve the date/time issue, and also improve compatibility with apps that don't read XMP.

- Phil
Title: Re: Photos.app .xmp date to .jpg
Post by: wywh on December 29, 2020, 12:34:13 PM
Thanks, this updates ExifIFD:DateTimeOriginal:

exiftool -tagsFromFile a.xmp -@ xmp2exif.args a.jpg

But (unless I am missing something) I must modify the args file to my needs because it copies only XMP-dc:Description to IFD0:ImageDescription which GraphicConverter ignores (Photos.app 6.0 does show it).

And it does not copy XMP-dc:Title and XMP-dc:Subject anywhere to the .jpg.

GraphicConverter (and Photos.app) use the these .xmp tags:

[XMP-dc]        Title                           : Object/Title text.
[XMP-dc]        Description                     : Caption/Description text.
[XMP-dc]        Subject                         : Keyword/Subject
[XMP-photoshop] DateCreated                     : 2000:01:01 12:00:00+03:00


GraphicConverter prefers these tags (and the corresponding XMP-dc tags, they are synchronised and I'd like to do the same also with exiftool) and ignores other similar tags:

[IPTC]          ObjectName                      : Object/Title text.
[IPTC]          Caption-Abstract                : Caption/Description text.
[IPTC]          Keywords                        : Keyword/Subject
[ExifIFD]       DateTimeOriginal                : 2000:01:01 12:00:00


p.s. I just discovered this great MetadataTestFile.jpg that nicely shows what tag each app happens to display:

https://exiftool.org/forum/index.php?topic=9212.0

- Matti
Title: Re: Photos.app .xmp date to .jpg
Post by: wywh on December 29, 2020, 03:30:33 PM
The following command seems to do what I want with these Photos.app .xmp sidecar files. It copies XMP-dc:Title, Description, Subject also to IPTC, and XMP-photoshop:DateCreated to ExifIFD:DateTimeOriginal and sets file creation & modification dates:

exiftool -m -overwrite_original_in_place -ext jpg -tagsfromfile %d%f.xmp -xmp:all '-IPTC:ObjectName<XMP-dc:Title' '-IPTC:Caption-Abstract<XMP-dc:Description' '-IPTC:Keywords<XMP-dc:Subject' '-ExifIFD:DateTimeOriginal<XMP-photoshop:DateCreated' '-FileCreateDate<XMP-photoshop:DateCreated' '-FileModifyDate<XMP-photoshop:DateCreated' .

Initially I made an args file but that also works although I guess it could be stylised way shorter and maybe I should forget those old IPTC tags anyway.
Title: Re: Photos.app .xmp date to .jpg
Post by: StarGeek on December 29, 2020, 03:58:01 PM
Quote from: wywh on December 29, 2020, 12:34:13 PM
And it does not copy XMP-dc:Title and XMP-dc:Subject anywhere to the .jpg.

That's because there isn't a corresponding tag in EXIF for those two tags.

QuoteGraphicConverter prefers these tags (and the corresponding XMP-dc tags, they are synchronised and I'd like to do the same also with exiftool) and ignores other similar tags:

[IPTC]          ObjectName                      : Object/Title text.
[IPTC]          Caption-Abstract                : Caption/Description text.
[IPTC]          Keywords                        : Keyword/Subject
[ExifIFD]       DateTimeOriginal                : 2000:01:01 12:00:00

Try the XMP2IPTC.args file.  You can see all the args files here (https://github.com/exiftool/exiftool/tree/master/arg_files).
Title: Re: Photos.app .xmp date to .jpg
Post by: wywh on December 30, 2020, 04:37:57 AM
Thanks for the note, I'll try those arg files. Hmm... maybe I should combine xmp2gps and xmp2iptc and grab just '-EXIF:DateTimeOriginal < XMP-photoshop:DateCreated' line from xmp2exif to a custom arg file for this purpose?

I'll use that handy MetadataTestFile.jpg to check if some of my apps really prefer any of those IPTC tags anymore. If not, I'll omit xmp2iptc. I also check if the apps are satisfied with only those XMP-exif:GPS* tags so xmp2gps might also be dropped. So my initial effort might not be so bad after all:

exiftool -m -overwrite_original_in_place -ext jpg -tagsfromfile %d%f.xmp -all:all '-ExifIFD:DateTimeOriginal<XMP-photoshop:DateCreated' '-FileCreateDate<XMP-photoshop:DateCreated' '-FileModifyDate<XMP-photoshop:DateCreated' .

What is currently considered the most future-proof tag or combination (EXIF, XMP, IPTC, etc)??
Title: Re: Photos.app .xmp date to .jpg
Post by: Phil Harvey on December 30, 2020, 12:07:36 PM
Things are moving in the direction of XMP instead of IPTC, but EXIF isn't going to go away any time soon.

- Phil
Title: Re: Photos.app .xmp date to .jpg
Post by: StarGeek on December 30, 2020, 12:12:58 PM
Quote from: wywh on December 30, 2020, 04:37:57 AM
Thanks for the note, I'll try those arg files. Hmm... maybe I should combine xmp2gps and xmp2iptc and grab just '-EXIF:DateTimeOriginal < XMP-photoshop:DateCreated' line from xmp2exif to a custom arg file for this purpose?

The GPS tags would be covered in the xmp2exif file. And you can run both in the same command with something like
exiftool -@ xmp2exif.args -@ xmp2iptc.args /path/to/files/

You could also use the -wm (writemode) option (https://exiftool.org/exiftool_pod.html#wm-MODE--writeMode) to make sure that any existing value isn't overwritten with -wm cg

QuoteI'll use that handy MetadataTestFile.jpg to check if some of my apps really prefer any of those IPTC tags anymore.

One thing to take note of is that a lot of programs don't actually seem to prefer one over the other.  It's more often that it's a case of whichever tag is first or last found.

QuoteI also check if the apps are satisfied with only those XMP-exif:GPS* tags so xmp2gps might also be dropped.

Personally, I would still copy the values to the EXIF GPS tags for future compatibility.  They're just more common in most programs.

QuoteWhat is currently considered the most future-proof tag or combination (EXIF, XMP, IPTC, etc)??

I don't think EXIF is going away.  It may be an older standard, but the goto place for most programs that read the camera settings.  For a camera to write XMP would add a whole other layer of complexity to the camera's firmware.  The XMP equivalents are rarely read.  Personally, I would love to drop IPTC support from my workflow.  XMP is so much better.  The only problem is that a couple of the programs I use don't read XMP, so I have to keep them in sync.  When I finally get off my butt and find some decent replacements, I'll completely remove IPTC from my files.
Title: Re: Photos.app .xmp date to .jpg
Post by: wywh on December 30, 2020, 01:05:26 PM
Yes, I noticed that the apps seem to pick the first tag they happen to see. Photos.app 6.0 seems to rely mainly on IPTC.

In my tests I needed to include -IPTC:CodedCharacterSet=UTF8 for the umlauts to display correctly but the test file was very blank in the beginning.

Is this kind of two arg file combination overkill and does it have any benefits or drawbacks. I didn't yet test the -wm switch:

exiftool -overwrite_original_in_place -ext jpg -IPTC:CodedCharacterSet=UTF8 -tagsFromFile %d%f.xmp -all:all -@ xmp2exif.args -@ xmp2iptc.args '-AllDates<XMP-photoshop:DateCreated' '-FileCreateDate<XMP-photoshop:DateCreated' '-FileModifyDate<XMP-photoshop:DateCreated' .

[Update: added -all:all which copies also those XMP tags to the jpg. Also removed xmp2gps.args. Sorry for updating the post just when StarGeek was replying to it.]
Title: Re: Photos.app .xmp date to .jpg
Post by: StarGeek on December 30, 2020, 03:39:46 PM
Quote from: wywh on December 30, 2020, 01:05:26 PM
These arg files seem not to copy the source .xmp file's XMP-exif and XMP-dc tags. How can I copy also them to the .jpg?

No it won't.  You have to tell exiftool to copy from one file to another.  See Example 15 (https://exiftool.org/metafiles.html#EX15) on the Metadata Sidecar Files (https://exiftool.org/metafiles.html) page.  It is important to either set the -ext (extension) option (https://exiftool.org/exiftool_pod.html#ext-EXT---ext-EXT--extension) to only the files extensions you want to process or to use it to exclude the XMP sidecars with --ext xmp (two hyphens) because otherwise you'll be copying the XMP sidecar back onto itself.

In my tests I needed to include -IPTC:CodedCharacterSet=UTF8 for the umlauts to display correctly but the test file was very blank in the beginning.

QuoteIs this kind of three arg file combination overkill and does it have any benefits or drawbacks. I didn't yet test the -wm switch:

The xmp2exif.args already copies everything the xmp2gps.args does, so the xmp2gps.args isn't necessary.
Title: Re: Photos.app .xmp date to .jpg
Post by: wywh on December 31, 2020, 01:06:49 PM
In summary: below is the cleaned command that combines all .jpg and .xmp files from Photos.app 6.0 (macOS 11 Big Sur) "Export Unmodified Original, Export IPTC as XMP" command. The output .jpg seems to work OK with Photos.app 6.0, Preview.app and GraphicConverter 11.3.3:

exiftool -overwrite_original_in_place -ext jpg -tagsFromFile %d%f.xmp -@ xmp2exif.args -@ xmp2iptc.args -all:all '-FileCreateDate<XMP-photoshop:DateCreated' '-FileModifyDate<XMP-photoshop:DateCreated' .

Those two args files must be in the current working directory, exiftool directory or in a specified path.

Even if '-IPTC:CodedCharacterSet=UTF8' is not already present in the .jpg, adding it does not seem to be needed (with that '-all:all' the High-ASCII characters display OK). I didn't use '-wm cg' because I want to update any old tags.

https://github.com/exiftool/exiftool/tree/master/arg_files

thanks,

- Matti
Title: Re: Photos.app .xmp date to .jpg
Post by: wywh on January 03, 2021, 05:43:43 AM
I am sorry but the saga continues. I wondered why sometimes exporting .xmp from Photos and copying its metadata to a .jpg puts it in a completely wrong location (exiftool 12.00).

It seems macOS 11.1 Big Sur Photos.app 6.0 "Export Unmodified Original, Export IPTC as XMP" omits minus (-) sign from western and southern hemisphere coordinates in the exported .xmp, right?

A test .jpg set in Santiago, Chile (all other metadata stripped off from the test file for clarity):

exiftool -a -G1 -s -n -ee '-gps*' a.jpg
[GPS]           GPSVersionID                    : 2 3 0 0
[GPS]           GPSLatitudeRef                  : S
[GPS]           GPSLatitude                     : 33.45
[GPS]           GPSLongitudeRef                 : W
[GPS]           GPSLongitude                    : 70.666667
[Composite]     GPSLatitude                     : -33.45
[Composite]     GPSLongitude                    : -70.666667
[Composite]     GPSPosition                     : -33.45 -70.666667


That is imported to Photos.app which correctly shows the location in Santiago, Chile. Then with no modifications whatsoever the image is exported via "Export Unmodified Original, Export IPTC as XMP" command as .jpg and .xmp (the same end result is seen if I really update the location in Photos to some location in southern or western hemisphere):

exiftool -a -G1 -s -n -ee '-gps*' a.* 
======== a.jpg
[GPS]           GPSVersionID                    : 2 3 0 0
[GPS]           GPSLatitudeRef                  : S
[GPS]           GPSLatitude                     : 33.45
[GPS]           GPSLongitudeRef                 : W
[GPS]           GPSLongitude                    : 70.666667
[Composite]     GPSLatitude                     : -33.45
[Composite]     GPSLongitude                    : -70.666667
[Composite]     GPSPosition                     : -33.45 -70.666667
======== a.xmp
[XMP-exif]      GPSImgDirection                 : 0.0
[XMP-exif]      GPSAltitudeRef                  : 0
[XMP-exif]      GPSAltitude                     : 0.0
[XMP-exif]      GPSLatitudeRef                  : S
[XMP-exif]      GPSLatitude                     : 33.45
[XMP-exif]      GPSLongitudeRef                 : W
[XMP-exif]      GPSImgDirectionRef              : T
[XMP-exif]      GPSLongitude                    : 70.66666667
[XMP-exif]      GPSSpeed                        : 0.0
[XMP-exif]      GPSSpeedRef                     : K
[XMP-exif]      GPSDateTime                     : 2020:11:28 08:16:37Z
[Composite]     GPSAltitude                     : 0.0
[Composite]     GPSLatitudeRef                  : N
[Composite]     GPSLongitudeRef                 : E
[Composite]     GPSPosition                     : 33.45 70.66666667


Then combine the "updated" .xmp to that original .jpg as described earlier in this thread (omitting '-all:all' or using only xmp2gps.args has the same end result):

exiftool -overwrite_original_in_place -ext jpg -tagsFromFile %d%f.xmp -@ xmp2exif.args -@ xmp2iptc.args -all:all .

Result:

exiftool -a -G1 -s -n -ee '-gps*' a.jpg
[GPS]           GPSVersionID                    : 2 3 0 0
[GPS]           GPSLatitudeRef                  : N
[GPS]           GPSLatitude                     : 33.45
[GPS]           GPSLongitudeRef                 : E
[GPS]           GPSLongitude                    : 70.66666667
[GPS]           GPSAltitudeRef                  : 0
[GPS]           GPSAltitude                     : 0
[GPS]           GPSTimeStamp                    : 08:16:37
[GPS]           GPSSpeedRef                     : K
[GPS]           GPSSpeed                        : 0
[GPS]           GPSImgDirectionRef              : T
[GPS]           GPSImgDirection                 : 0
[GPS]           GPSDateStamp                    : 2020:11:28
[XMP-exif]      GPSAltitude                     : 0
[XMP-exif]      GPSAltitudeRef                  : 0
[XMP-exif]      GPSImgDirection                 : 0
[XMP-exif]      GPSImgDirectionRef              : T
[XMP-exif]      GPSLatitude                     : 33.45
[XMP-exif]      GPSLongitude                    : 70.66666667
[XMP-exif]      GPSSpeed                        : 0
[XMP-exif]      GPSSpeedRef                     : K
[XMP-exif]      GPSDateTime                     : 2020:11:28 08:16:37Z
[Composite]     GPSAltitude                     : 0
[Composite]     GPSDateTime                     : 2020:11:28 08:16:37Z
[Composite]     GPSLatitude                     : 33.45
[Composite]     GPSLongitude                    : 70.66666667
[Composite]     GPSLatitudeRef                  : N
[Composite]     GPSLongitudeRef                 : E
[Composite]     GPSPosition                     : 33.45 70.66666667


Doesn't the missing a minus (-) sign in the .xmp latitude and longitude cause the .jpg to be put on the other side of the globe near Islamabad, Pakistan (33.45, 70.666667), right?

[GPS]           GPSLatitudeRef                  : N
[GPS]           GPSLatitude                     : 33.45
[GPS]           GPSLongitudeRef                 : E
[GPS]           GPSLongitude                    : 70.66666667
[XMP-exif]      GPSLatitude                     : 33.45
[XMP-exif]      GPSLongitude                    : 70.66666667
[Composite]     GPSLatitude                     : 33.45
[Composite]     GPSLongitude                    : 70.66666667
[Composite]     GPSLatitudeRef                  : N
[Composite]     GPSLongitudeRef                 : E
[Composite]     GPSPosition                     : 33.45 70.66666667


A related note: somehow GraphicConverter 11.3.3's command "...XMP Sidecar File > Copy into JPGs, TIFFs, PNGs, webp, HEICs" manages the output so that my apps tells me it is still in Santiago, Chile although there there are some missing minus signs and mixed S and W letters:

exiftool -a -G1 -s -n -ee '-gps*' a.jpg
[GPS]           GPSVersionID                    : 2 3 0 0
[GPS]           GPSLatitudeRef                  : S
[GPS]           GPSLatitude                     : 33.45
[GPS]           GPSLongitudeRef                 : W
[GPS]           GPSLongitude                    : 70.6666666666667
[XMP-exif]      GPSAltitude                     : 0.0
[XMP-exif]      GPSAltitudeRef                  : 0
[XMP-exif]      GPSImgDirection                 : 0.0
[XMP-exif]      GPSImgDirectionRef              : T
[XMP-exif]      GPSLatitude                     : 33.45
[XMP-exif]      GPSLatitudeRef                  : S
[XMP-exif]      GPSLongitude                    : 70.66666667
[XMP-exif]      GPSLongitudeRef                 : W
[XMP-exif]      GPSSpeed                        : 0.0
[XMP-exif]      GPSSpeedRef                     : K
[XMP-exif]      GPSDateTime                     : 2020:11:28 08:16:37Z
[Composite]     GPSAltitude                     : 0.0
[Composite]     GPSLatitude                     : -33.45
[Composite]     GPSLongitude                    : -70.6666666666667
[Composite]     GPSLatitudeRef                  : N
[Composite]     GPSLongitudeRef                 : E
[Composite]     GPSPosition                     : -33.45 -70.6666666666667


If in Photos I paste location -33.45, -70.666667, the exported .xmp is also missing the minus signs and in Photos seems to force some other nearby location (AFAIK there are scripts to bypass this and insert an exact location):

exiftool -a -G1 -s -n -ee '-gps*' a.xmp
[XMP-exif]      GPSLongitude                    : 70.638756
[XMP-exif]      GPSLongitudeRef                 : W
[XMP-exif]      GPSHPositioningError            : 1
[XMP-exif]      GPSLatitudeRef                  : S
[XMP-exif]      GPSLatitude                     : 33.614528
[XMP-exif]      GPSDateTime                     : 2021:01:03 10:34:00Z
[Composite]     GPSLatitudeRef                  : N
[Composite]     GPSLongitudeRef                 : E
[Composite]     GPSPosition                     : 33.614528 70.638756


A workaround is to use a text editor to add the minus signs to the offending .xmp files but I'll wait if Apple fixes this.
Title: Re: Photos.app .xmp date to .jpg
Post by: StarGeek on January 03, 2021, 10:13:42 AM
Quote from: wywh on January 03, 2021, 05:43:43 AM
It seems macOS 11.1 Big Sur Photos.app 6.0 "Export Unmodified Original, Export IPTC as XMP" omits minus (-) sign from western and southern hemisphere coordinates in the exported .xmp, right?

I'm really starting to have the opinion that Apple Photos is a really badly written application.  For some reason it's decided to write the directional references separately to XMP, even though the spec specifically says not to do so.

Try changing the command like this
-tagsFromFile %d%f.xmp -@ xmp2exif.args -GPS*Ref

That should copy any GPS reference to the appropriate place in the EXIF block.  You want to have it after the xmp2exif.args because that args file will already copy GPS values and this will override that copy operation.
Title: Re: Photos.app .xmp date to .jpg
Post by: wywh on January 04, 2021, 01:03:38 PM
Thanks for the tip. So this is the flawed sidecar .xmp from Photos.app 6.0:

<x:xmpmeta xmlns:x="adobe:ns:meta/" x:xmptk="XMP Core 6.0.0">
   <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
      <rdf:Description rdf:about=""
            xmlns:exif="http://ns.adobe.com/exif/1.0/"
            xmlns:photoshop="http://ns.adobe.com/photoshop/1.0/">
         <exif:GPSImgDirection>0.0</exif:GPSImgDirection>
         <exif:GPSAltitudeRef>0</exif:GPSAltitudeRef>
         <exif:GPSAltitude>0.0</exif:GPSAltitude>
         <exif:GPSLatitudeRef>S</exif:GPSLatitudeRef>
         <exif:GPSLatitude>33.450000000000003</exif:GPSLatitude>
         <exif:GPSLongitudeRef>W</exif:GPSLongitudeRef>
         <exif:GPSImgDirectionRef>T</exif:GPSImgDirectionRef>
         <exif:GPSLongitude>70.666666670000012</exif:GPSLongitude>
         <exif:GPSSpeed>0.0</exif:GPSSpeed>
         <exif:GPSSpeedRef>K</exif:GPSSpeedRef>
         <exif:GPSTimeStamp>2020-11-28T08:16:37Z</exif:GPSTimeStamp>
         <photoshop:DateCreated>2020-11-28T10:16:37+02:00</photoshop:DateCreated>
      </rdf:Description>
   </rdf:RDF>
</x:xmpmeta>


I tried your tip slightly modified as a workaround but it seems to omit both incorrect and correct latitude and longitude references so it fails to properly update them or insert them to a blank file (I omitted '-all:all' so it does not copy that conflicting data to the .jpg):

exiftool -overwrite_original_in_place -ext jpg -tagsFromFile %d%f.xmp -@ xmp2exif.args '--GPS*Ref' -@ xmp2iptc.args .

Anyway, which are the correct formats for GPS data in .xmp:

<exif:GPSLatitude>-33.45</exif:GPSLatitude>
<exif:GPSLongitude>-70.66666667</exif:GPSLongitude>

<exif:GPSLatitude>33.45S</exif:GPSLatitude>
<exif:GPSLongitude>70.66666667W</exif:GPSLongitude>

<exif:GPSLatitude>33 deg 27' 0.00" S</exif:GPSLatitude>
<exif:GPSLongitude>70 deg 40' 0.00" W</exif:GPSLongitude>


This does not seem to work (the location is somewhat different as an end result):

<exif:GPSLatitude>-33 deg 27' 0.00"</exif:GPSLatitude>
<exif:GPSLongitude>-70 deg 40' 0.00"</exif:GPSLongitude>


And none of the following should be used, right?

<exif:GPSLatitudeRef>S</exif:GPSLatitudeRef>
<exif:GPSLongitudeRef>W</exif:GPSLongitudeRef>

- Matti
Title: Re: Photos.app .xmp date to .jpg
Post by: Phil Harvey on January 04, 2021, 01:42:50 PM
From the EXIF 2.31 metadata for XMP specification (http://www.cipa.jp/std/documents/e/DC-X010-2017.pdf):

Value type of GPSCoodinate is a Text value in the form "DDD,MM,SSk" or "DDD,MM.mmk", where:
• DDD is a number of degrees
• MM is a number of minutes
• SS is a number of seconds
• mm is a fraction of minutes
• k is a single character N, S, E, or W indicating a direction (north, south, east, west)

- Phil
Title: Re: Photos.app .xmp date to .jpg
Post by: StarGeek on January 04, 2021, 02:09:07 PM
Quote from: wywh on January 04, 2021, 01:03:38 PM
I tried your tip slightly modified as a workaround but it seems to omit both incorrect and correct latitude and longitude references so it fails to properly update them or insert them to a blank file (I omitted '-all:all' so it does not copy that conflicting data to the .jpg):

exiftool -overwrite_original_in_place -ext jpg -tagsFromFile %d%f.xmp -@ xmp2exif.args '--GPS*Ref' -@ xmp2iptc.args .

You used two dashes.  That tells exiftool not to copy those tags.
Title: Re: Photos.app .xmp date to .jpg
Post by: wywh on January 05, 2021, 10:50:16 AM
Quote from: StarGeek on January 04, 2021, 02:09:07 PM
You used two dashes.  That tells exiftool not to copy those tags.

I first did try it with one dash but as it did not work (despite added 'single quotes'), I presumed two dashes were needed two get rid of the erroneous references.

With single dash '-GPS*Ref' it still sets latitude and longitude references wrong. Am I still missing something or does this workaround need more ammo?

#Photos.app 6.0 image at Santiago, Chile (-33.45, -70.666667). "Export Unmodified Original, Export IPTC as XMP" original .jpg with .xmp metadata
#(original was not updated but it makes do difference if the location is updated in Photos.app):

exiftool -a -G1 -s -ee '-gps*' .   
======== ./a.jpg
[GPS]           GPSVersionID                    : 2.3.0.0
[GPS]           GPSLatitudeRef                  : South
[GPS]           GPSLatitude                     : 33 deg 27' 0.00"
[GPS]           GPSLongitudeRef                 : West
[GPS]           GPSLongitude                    : 70 deg 40' 0.00"
[Composite]     GPSLatitude                     : 33 deg 27' 0.00" S
[Composite]     GPSLongitude                    : 70 deg 40' 0.00" W
[Composite]     GPSPosition                     : 33 deg 27' 0.00" S, 70 deg 40' 0.00" W
======== ./a.xmp
[XMP-exif]      GPSImgDirection                 : 0.0
[XMP-exif]      GPSAltitudeRef                  : Above Sea Level
[XMP-exif]      GPSAltitude                     : 0.0 m
[XMP-exif]      GPSLatitudeRef                  : S
[XMP-exif]      GPSLatitude                     : 33 deg 27' 0.00" N
[XMP-exif]      GPSLongitudeRef                 : W
[XMP-exif]      GPSImgDirectionRef              : True North
[XMP-exif]      GPSLongitude                    : 70 deg 40' 0.00" E
[XMP-exif]      GPSSpeed                        : 0.0
[XMP-exif]      GPSSpeedRef                     : km/h
[XMP-exif]      GPSDateTime                     : 2020:11:28 08:16:37Z
[Composite]     GPSAltitude                     : 0 m Above Sea Level
[Composite]     GPSLatitudeRef                  : North
[Composite]     GPSLongitudeRef                 : East
[Composite]     GPSPosition                     : 33 deg 27' 0.00" N, 70 deg 40' 0.00" E

#Updated .xmp metadata copied to .jpg:

exiftool -overwrite_original_in_place -ext jpg -tagsFromFile %d%f.xmp -@ xmp2exif.args '-GPS*Ref' -@ xmp2iptc.args .
    1 directories scanned
    1 image files updated

exiftool -a -G1 -s -ee '-gps*' a.jpg
[GPS]           GPSVersionID                    : 2.3.0.0
[GPS]           GPSLatitudeRef                  : North
[GPS]           GPSLatitude                     : 33 deg 27' 0.00"
[GPS]           GPSLongitudeRef                 : East
[GPS]           GPSLongitude                    : 70 deg 40' 0.00"
[GPS]           GPSAltitudeRef                  : Above Sea Level
[GPS]           GPSAltitude                     : 0 m
[GPS]           GPSTimeStamp                    : 08:16:37
[GPS]           GPSSpeedRef                     : km/h
[GPS]           GPSSpeed                        : 0
[GPS]           GPSImgDirectionRef              : True North
[GPS]           GPSImgDirection                 : 0
[GPS]           GPSDateStamp                    : 2020:11:28
[Composite]     GPSAltitude                     : 0 m Above Sea Level
[Composite]     GPSDateTime                     : 2020:11:28 08:16:37Z
[Composite]     GPSLatitude                     : 33 deg 27' 0.00" N
[Composite]     GPSLongitude                    : 70 deg 40' 0.00" E
[Composite]     GPSPosition                     : 33 deg 27' 0.00" N, 70 deg 40' 0.00" E

#Result: Photos.app 6.0, Preview.app and GraphicConverter 11.3.3 see the location on the other side of the globe near Islamabad, Pakistan (33.45, 70.666667)


I hope Apple will fix this soon. But there are even more serious location problems affecting also older macOS. This does not much affect me personally as I edit all metadata outside Photos.app and use it only as a viewer and an aid to sync to iOS devices (there have been big problems also with that and two years ago in desperation I even emailed Tim Cook but instead of a Jobsian moment and a quick fix I only got a boilerplate reply from some secretary).

https://discussions.apple.com/thread/251905264
Title: Re: Photos.app .xmp date to .jpg
Post by: StarGeek on January 05, 2021, 12:25:26 PM
Ah, I see my mistake.  The composite GPS references are taking priority over the XMP references.  Try this
exiftool -overwrite_original_in_place -ext jpg -tagsFromFile %d%f.xmp -@ xmp2exif.args '-exif:gps*ref<xmp:gps*ref' -@ xmp2iptc.args .

That seemed to work for me
C:\>exiftool -P -overwrite_original -TagsFromFile temp.xmp -@ xmp2exif.args "-exif:gps*ref<xmp:gps*ref"  y:\!temp\Test4.jpg
    1 image files updated

C:\>exiftool -g1 -a -s -gps* y:\!temp\Test4.jpg
---- GPS ----
GPSVersionID                    : 2.3.0.0
GPSLatitudeRef                  : South
GPSLatitude                     : 33 deg 27' 0.00"
GPSLongitudeRef                 : West
GPSLongitude                    : 70 deg 40' 0.00"
GPSAltitudeRef                  : Above Sea Level
GPSAltitude                     : 0 m
GPSTimeStamp                    : 08:16:37
GPSSpeedRef                     : knots
GPSSpeed                        : 0
GPSTrackRef                     : True North
GPSImgDirectionRef              : True North
GPSImgDirection                 : 0
GPSDestLatitudeRef              : South
GPSDestLongitudeRef             : West
GPSDestBearingRef               : True North
GPSDateStamp                    : 2020:11:28
---- Composite ----
GPSAltitude                     : 0 m Above Sea Level
GPSDateTime                     : 2020:11:28 08:16:37Z
GPSLatitude                     : 33 deg 27' 0.00" S
GPSLongitude                    : 70 deg 40' 0.00" W
GPSPosition                     : 33 deg 27' 0.00" S, 70 deg 40' 0.00" W
Title: Re: Photos.app .xmp date to .jpg
Post by: wywh on January 05, 2021, 04:16:07 PM
> The composite GPS references are taking priority over the XMP references.

Thanks! I was under the impression that the composite tags can be ignored but obviously that is not true?

Now it works OK and preserves the correct hemispheres.

The only remaining weirdness is that the following tags are changed to below sea level and knots:

[GPS]           GPSAltitudeRef                  : Below Sea Level
[GPS]           GPSSpeedRef                     : knots


exiftool -a -G1 -s -ee '-gps*' .                                                                                                     
======== ./a.jpg
[GPS]           GPSLatitudeRef                  : North
[GPS]           GPSLatitude                     : 62 deg 46' 19.98"
[GPS]           GPSLongitudeRef                 : East
[GPS]           GPSLongitude                    : 22 deg 49' 14.90"
[GPS]           GPSAltitudeRef                  : Above Sea Level
[GPS]           GPSAltitude                     : 92 m
[GPS]           GPSTimeStamp                    : 08:16:36.28
[GPS]           GPSSpeedRef                     : km/h
[GPS]           GPSSpeed                        : 0
[GPS]           GPSImgDirectionRef              : True North
[GPS]           GPSImgDirection                 : 237.7672414
[GPS]           GPSDestBearingRef               : True North
[GPS]           GPSDestBearing                  : 237.7672414
[GPS]           GPSDateStamp                    : 2020:11:28
[GPS]           GPSHPositioningError            : 5 m
[Composite]     GPSAltitude                     : 92 m Above Sea Level
[Composite]     GPSDateTime                     : 2020:11:28 08:16:36.28Z
[Composite]     GPSLatitude                     : 62 deg 46' 19.98" N
[Composite]     GPSLongitude                    : 22 deg 49' 14.90" E
[Composite]     GPSPosition                     : 62 deg 46' 19.98" N, 22 deg 49' 14.90" E
======== ./a.xmp
[XMP-exif]      GPSLongitude                    : 70 deg 40' 1.41" E
[XMP-exif]      GPSLongitudeRef                 : W
[XMP-exif]      GPSHPositioningError            : 1 m
[XMP-exif]      GPSLatitude                     : 33 deg 26' 45.58" N
[XMP-exif]      GPSLatitudeRef                  : S
[XMP-exif]      GPSDateTime                     : 2021:01:05 19:47:45Z
[Composite]     GPSLatitudeRef                  : North
[Composite]     GPSLongitudeRef                 : East
[Composite]     GPSPosition                     : 33 deg 26' 45.58" N, 70 deg 40' 1.41" E

exiftool -overwrite_original_in_place -ext jpg -tagsFromFile %d%f.xmp -@ xmp2exif.args '-exif:gps*ref<xmp:gps*ref' -@ xmp2iptc.args .
    1 directories scanned
    1 image files updated

exiftool -a -G1 -s -ee '-gps*' *.jpg                                                                                                 
[GPS]           GPSLatitudeRef                  : South
[GPS]           GPSLatitude                     : 33 deg 26' 45.58"
[GPS]           GPSLongitudeRef                 : West
[GPS]           GPSLongitude                    : 70 deg 40' 1.41"
[GPS]           GPSAltitudeRef                  : Below Sea Level
[GPS]           GPSAltitude                     : 92 m
[GPS]           GPSTimeStamp                    : 19:47:45
[GPS]           GPSSpeedRef                     : knots
[GPS]           GPSSpeed                        : 0
[GPS]           GPSImgDirectionRef              : True North
[GPS]           GPSImgDirection                 : 237.7672414
[GPS]           GPSDestLatitudeRef              : South
[GPS]           GPSDestLongitudeRef             : West
[GPS]           GPSDestBearingRef               : True North
[GPS]           GPSDestBearing                  : 237.7672414
[GPS]           GPSDateStamp                    : 2021:01:05
[GPS]           GPSHPositioningError            : 1 m
[Composite]     GPSAltitude                     : 92 m Below Sea Level
[Composite]     GPSDateTime                     : 2021:01:05 19:47:45Z
[Composite]     GPSLatitude                     : 33 deg 26' 45.58" S
[Composite]     GPSLongitude                    : 70 deg 40' 1.41" W
[Composite]     GPSPosition                     : 33 deg 26' 45.58" S, 70 deg 40' 1.41" W
Title: Re: Photos.app .xmp date to .jpg
Post by: StarGeek on January 05, 2021, 04:43:59 PM
Quote from: wywh on January 05, 2021, 04:16:07 PM
Thanks! I was under an impression that the composite tags can be ignored but obviously this is not true?

When you copy a tag and don't name the group you're copying from, then Composite tags will be the ones copied if they exist for that tag name.  This case was unusual because, AFAIK, there ususally isn't a Composite GPS reference tag.

QuoteThe only remaining weirdness is that the following tags are changed to below sea level and knots:

[GPS]           GPSAltitudeRef                  : Below Sea Level
[GPS]           GPSSpeedRef                     : knots

I was trying to be tricky and shorten the command, but since it becomes a problem with the other two tags, it's probably best to be explicit with the copy.
"-GPS:GPSLatitudeRef<XMP:GPSLatitudeRef" "-GPS:GPSLongitudeRef<XMP:GPSLongitudeRef"
Title: Re: Photos.app .xmp date to .jpg
Post by: Phil Harvey on January 05, 2021, 09:44:37 PM
Quote from: StarGeek on January 05, 2021, 04:43:59 PM
there ususally isn't a Composite GPS reference tag.

Composite:GPSLatitudeRef is generated from XMP-exif:GPSLatitude (if that's what you're talking about, see here (https://exiftool.org/TagNames/Composite.html)).  These Composite tags are used by xmp2gps.args when converting XMP to EXIF GPS.

- Phil
Title: Re: Photos.app .xmp date to .jpg
Post by: wywh on January 06, 2021, 07:47:18 AM
Quote from: StarGeek on January 05, 2021, 04:43:59 PM
it's probably best to be explicit with the copy.
"-GPS:GPSLatitudeRef<XMP:GPSLatitudeRef" "-GPS:GPSLongitudeRef<XMP:GPSLongitudeRef"

Thanks! The following command seems to bypass those GPS reference flaws in the Photos.app 6.0 .xmp:

exiftool -overwrite_original_in_place -ext jpg '-IPTC:CodedCharacterSet=UTF8' -tagsFromFile %d%f.xmp -@ xmp2exif.args '-GPS:GPSLatitudeRef<XMP:GPSLatitudeRef' '-GPS:GPSLongitudeRef<XMP:GPSLongitudeRef' -@ xmp2iptc.args '-XMP-photoshop:DateCreated<XMP-photoshop:DateCreated' '-FileCreateDate<XMP-photoshop:DateCreated' '-FileModifyDate<XMP-photoshop:DateCreated' .

The workaround has the following changes:

'-IPTC:CodedCharacterSet=UTF8' added so High-ASCII umlauts in the IPTC metadata are correctly copied to .jpg files with blank metadata (the normal command containing '-all:all' seems handle this without this addition).

'-GPS:GPSLatitudeRef<XMP:GPSLatitudeRef' and '-GPS:GPSLongitudeRef<XMP:GPSLongitudeRef' added so the correct references are copied.

'-all:all' omitted because it would copy erroneous references to .jpg but '-XMP-photoshop:DateCreated<XMP-photoshop:DateCreated' added because if such .jpg is imported back to Photos.app 6.0, it would otherwise get the date from the old 'XMP-photoshop:DateCreated' instead 'ExifIFD:DateTimeOriginal'. Isn't it weird that it does not prefer DateTimeOriginal?

If that Photos.app 6.0 .xmp flaw is fixed, the following shorter command should work. Older Photos.app versions export different .xmp and Photos.app 4.0 seems to have 'photoshop:DateCreated' and 'photomechanic:TimeCreated' date and time tags.

exiftool -overwrite_original_in_place -ext jpg -tagsFromFile %d%f.xmp -@ xmp2exif.args -@ xmp2iptc.args '-all:all' '-FileCreateDate<XMP-photoshop:DateCreated' '-FileModifyDate<XMP-photoshop:DateCreated' .