Photos.app .xmp date to .jpg

Started by wywh, December 28, 2020, 01:51:49 PM

Previous topic - Next topic

wywh

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

Phil Harvey

You could populate all EXIF tags using this arg file.

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

- 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

#2
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

wywh

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.

StarGeek

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.
* Did you read FAQ #3 and use the command listed there?
* Please use the Code button for exiftool code/output.
 
* Please include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).

wywh

#5
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)??

Phil Harvey

Things are moving in the direction of XMP instead of IPTC, but EXIF isn't going to go away any time soon.

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

StarGeek

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 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.
* Did you read FAQ #3 and use the command listed there?
* Please use the Code button for exiftool code/output.
 
* Please include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).

wywh

#8
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.]

StarGeek

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 on the Metadata Sidecar Files page.  It is important to either set the -ext (extension) option 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.
* Did you read FAQ #3 and use the command listed there?
* Please use the Code button for exiftool code/output.
 
* Please include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).

wywh

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

wywh

#11
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.

StarGeek

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.
* Did you read FAQ #3 and use the command listed there?
* Please use the Code button for exiftool code/output.
 
* Please include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).

wywh

#13
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

Phil Harvey

From the EXIF 2.31 metadata for XMP specification:

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