Date from XMP-photoshop:DateCreated instead ExifIFD:DateTimeOriginal

Started by wywh, June 05, 2022, 10:34:12 AM

Previous topic - Next topic

wywh

For a moment I thought all .jpg image dates were finally OK in my workflow.

But macOS 12.4 Photos.app 7.0 and Preview.app seem to get the date and time from 'XMP-photoshop:DateCreated' that might lack time so the time is displayed as 0.00.00 and images are sorted incorrectly (for some reason more current images have also time in 'XMP-photoshop:DateCreated' so they are OK):

exiftool -a -G1 -s -time:all 2017-0103-1508-06.jpg
[System]        FileModifyDate                  : 2017:01:03 15:08:06+02:00
[System]        FileAccessDate                  : 2022:06:05 17:23:58+03:00
[System]        FileInodeChangeDate             : 2022:06:05 17:23:57+03:00
[IFD0]          ModifyDate                      : 2017:01:12 18:00:57
[ExifIFD]       DateTimeOriginal                : 2017:01:03 15:08:06
[ExifIFD]       CreateDate                      : 2017:01:03 15:08:06
[ExifIFD]       SubSecTimeOriginal              : 00
[ExifIFD]       SubSecTimeDigitized             : 00
[ICC-header]    ProfileDateTime                 : 1998:02:09 06:49:00
[IPTC]          DateCreated                     : 2017:01:03
[IPTC]          TimeCreated                     : 15:08:06
[IPTC]          DigitalCreationDate             : 2017:01:03
[IPTC]          DigitalCreationTime             : 15:08:06
[XMP-xmp]       ModifyDate                      : 2017:01:12 18:00:57+02:00
[XMP-xmp]       CreateDate                      : 2017:01:03 15:08:06.00
[XMP-xmp]       MetadataDate                    : 2017:01:12 18:00:57+02:00
[XMP-photoshop] DateCreated                     : 2017:01:03
[XMP-xmpMM]     HistoryWhen                     : 2017:01:12 18:00:57+02:00
[Composite]     SubSecCreateDate                : 2017:01:03 15:08:06.00
[Composite]     SubSecDateTimeOriginal          : 2017:01:03 15:08:06.00
[Composite]     DateTimeCreated                 : 2017:01:03 15:08:06
[Composite]     DigitalCreationDateTime         : 2017:01:03 15:08:06


What is the best way to fix this (both seem to work)?

a) Remove 'XMP-photoshop:DateCreated':

exiftool -m -P -overwrite_original_in_place -if '$XMP-photoshop:DateCreated' -XMP-photoshop:DateCreated= .

b) Add time to 'XMP-photoshop:DateCreated'. But if 'ExifIFD:DateTimeOriginal' is modified, the error might kick in again.

exiftool -m -P -overwrite_original_in_place -if '$XMP-photoshop:DateCreated' '-XMP-photoshop:DateCreated<ExifIFD:DateTimeOriginal' .

Is it possible to modify only images lacking time in 'XMP-photoshop:DateCreated' so I don't touch images that are OK?

- Matti

StarGeek

Quote from: wywh on June 05, 2022, 10:34:12 AM
Is it possible to modify only images lacking time in 'XMP-photoshop:DateCreated' so I don't touch images that are OK?

You could use
exiftool -if "not $XMP-photoshop:DateCreated=~/ \d\d:\d\d:\d\d/" -XMP-photoshop:DateCreated= /path/to/files/

Note that there's a space before the first \d.
* 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

Quote from: StarGeek on June 05, 2022, 10:48:50 AM
You could use

Thanks for the speedy reply!

I can now move only offending images to a subfolder and see how widespread this error is:

exiftool -if 'not $XMP-photoshop:DateCreated=~/ \d\d:\d\d:\d\d/' '-Directory=./0_XMP-photoshop_DateCreated_notime' .

...hmm... it seems not all such images display time as 0.00.00 ... maybe this is IPTC time related after all although I thought I had already fixed them ... but many offending images have correct IPTC date and time ... maybe I should rebuild metadata of ALL images <sigh> But I'd rather not do such global edit to all images because one app is misbehaving [edit: rebuilding metadata does not fix this].

https://exiftool.org/forum/index.php?topic=11581.msg62128#msg62128

p.s. IMHO it is weird that Photos.app 7.0 seems to prefer 'XMP-photoshop:DateCreated' instead 'ExifIFD:DateTimeOriginal'. It also still exports .xmp sidecar GPS in a wrong format (I have sent feedback to Apple about this a few times):

<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>36.610100000000003</exif:GPSLatitude>
         <exif:GPSLongitudeRef>W</exif:GPSLongitudeRef>
         <exif:GPSImgDirectionRef>T</exif:GPSImgDirectionRef>
         <exif:GPSLongitude>66.915149999999997</exif:GPSLongitude>
         <exif:GPSSpeed>0.0</exif:GPSSpeed>
         <exif:GPSSpeedRef>K</exif:GPSSpeedRef>
         <exif:GPSTimeStamp>2017-01-02T22:00:00Z</exif:GPSTimeStamp>
         <photoshop:DateCreated>2017-01-03T00:00:00+02:00</photoshop:DateCreated>
      </rdf:Description>
   </rdf:RDF>
</x:xmpmeta>


- Matti

wywh

Quote from: StarGeek on June 05, 2022, 10:48:50 AM
You could use
exiftool -if "not $XMP-photoshop:DateCreated=~/ \d\d:\d\d:\d\d/" -XMP-photoshop:DateCreated= /path/to/files/

[images lacking time in 'XMP-photoshop:DateCreated' display time as 0.00.00 in macOS 12.4 Monterey Photos.app]

Is the '~/ \d\d:\d\d:\d\d/' part explained somewhere in exiftool manual? I'd like to know what I am doing although it works...

So this seems to fix the missing time in macOS 12.4 Monterey Photos.app:

exiftool -m -P -overwrite_original_in_place -if 'not $XMP-photoshop:DateCreated=~/ \d\d:\d\d:\d\d/' -XMP-photoshop:DateCreated= .

... as a fly in the ointment, Photos.app shows the time for some images missing that time tag there but maybe it then grabs the time from 'XMP-exif:DateTimeOriginal' that happens to be there in just those images ... oh, so many variables! I wish apps only look for 'ExifIFD:DateTimeOriginal' and ignore other date tags in .jpg.

- Matti

StarGeek

Quote from: wywh on June 10, 2022, 12:52:16 PM
Is the '~/ \d\d:\d\d:\d\d/' part explained somewhere in exiftool manual? I'd like to know what I am doing although it works...

Not in detail.  It is part of the Advanced formatting feature.  It is using Perl code to do the comparison.  Here, the command uses the Perl Binding Operator to do a Regular Expression (RegEx) comparison to the tag value.  RegEx is a whole thing in itself and best learned through the many RegEx tutorials that can be found upon the web.  Also useful is sites like Regex101 which will show you what a RegEx will match and break down each step.  Using the above RegEx, you can see and test matching here.

Quoteas a fly in the ointment, Photos.app shows the time for some images missing that time tag there but maybe it then grabs the time from 'XMP-exif:DateTimeOriginal' that happens to be there in just those images

One thing I determined in my testing is that a lot of programs don't necessarily have a hierarchy of which tags they will read.  It may be the first tag that it finds or the last or anything in between.
* 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


Phil Harvey

Quote from: StarGeek on June 10, 2022, 02:09:13 PM
Quote from: wywh on June 10, 2022, 12:52:16 PM
Is the '~/ \d\d:\d\d:\d\d/' part explained somewhere in exiftool manual? I'd like to know what I am doing although it works...

Not in detail.  It is part of the Advanced formatting feature.

It looks like you are using Perl code in a -if condition, not an advanced formatting expression.  Same idea though.

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

StarGeek

* 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).