ExifTool Forum

ExifTool => The "exiftool" Application => Topic started by: jojomimi on January 30, 2020, 05:31:09 AM

Title: Parameters for creating [EXIF] DateTimeOriginal - tag
Post by: jojomimi on January 30, 2020, 05:31:09 AM
Hi,

I'm on Linux Mint.  For some reason, I'm missing the "DateTimeOriginal" info in many of my pictures but I could use "FileModifyDate" as this one seems to be close to the timestamp I'm looking for.

Question :
I can't find how to create the "[EXIF] DateTimeOriginal" - tag.
I also can't find how to copy the "[File] FileModifyDate" value into this field.

Example :

exiftool -G -s 8576d6366939e3fe0000000000000000.jpg

[ExifTool]      ExifToolVersion                 : 10.80
[File]          FileName                        : 8576d6366939e3fe0000000000000000.jpg
[File]          Directory                       : .
[File]          FileSize                        : 70 kB
[File]          FileModifyDate                  : 2018:01:04 11:51:14+01:00
[File]          FileAccessDate                  : 2020:01:29 23:33:27+01:00
[File]          FileInodeChangeDate             : 2020:01:27 21:52:50+01:00
[File]          FilePermissions                 : rwxrwxrwx
[File]          FileType                        : JPEG
[File]          FileTypeExtension               : jpg
[File]          MIMEType                        : image/jpeg
[File]          ExifByteOrder                   : Little-endian (Intel, II)
[File]          ImageWidth                      : 1183
[File]          ImageHeight                     : 360
[File]          EncodingProcess                 : Baseline DCT, Huffman coding
[File]          BitsPerSample                   : 8
[File]          ColorComponents                 : 3
[File]          YCbCrSubSampling                : YCbCr4:2:0 (2 2)
[JFIF]          JFIFVersion                     : 1.01
[EXIF]          Software                        : Picasa
[EXIF]          ExifVersion                     : 0220
[EXIF]          ColorSpace                      : sRGB
[EXIF]          ExifImageWidth                  : 1183
[EXIF]          ExifImageHeight                 : 360
[EXIF]          InteropIndex                    : R98 - DCF basic file (sRGB)
[EXIF]          InteropVersion                  : 0100
[EXIF]          ImageUniqueID                   : 8576d6366939e3fe0000000000000000
[EXIF]          Compression                     : JPEG (old-style)
[EXIF]          XResolution                     : 72
[EXIF]          YResolution                     : 72
[EXIF]          ResolutionUnit                  : inches
[EXIF]          ThumbnailOffset                 : 312
[EXIF]          ThumbnailLength                 : 3320
[EXIF]          ThumbnailImage                  : (Binary data 3320 bytes, use -b option to extract)
[XMP]           XMPToolkit                      : XMP Core 5.5.0
[Composite]     ImageSize                       : 1183x360
[Composite]     Megapixels                      : 0.426

I want to copy the FileModifyDate value ("2018:01:04 11:51:14+01:00") into below fields, if they don't exist yet in my picture :
[EXIF]          DateTimeOriginal                :
[EXIF]          CreateDate                      :

Can someone help me ?
Title: Re: Parameters for creating [EXIF] DateTimeOriginal - tag
Post by: Phil Harvey on January 30, 2020, 07:19:44 AM
There is lots of wiggle room here.  To fill in DateTimeOriginal and CreateDate with FileModifyDate if they are empty, you can do this:

exiftool -addtagsfromfile @ -datetimeoriginal-= "-datetimeoriginal<filemodifydate" -createdate-= "-createdate<filemodifydate" FILESorDIRS

But I would think it would be better to fill in CreateDate with DateTimeOriginal if it exists, and visa versa, and only use FileModifyDate if necessary:

exiftool -addtagsfromfile @ -datetimeoriginal-= "-datetimeoriginal<filemodifydate" "-datetimeoriginal<createdate" -createdate-= "-createdate<filemodifydate" "-createdate<datetimeoriginal" FILESorDIRS

- Phil
Title: Re: Parameters for creating [EXIF] DateTimeOriginal - tag
Post by: jojomimi on January 30, 2020, 07:41:22 AM
Hi Phil,

What a quick reply !  I'll test this tonight.

I forgot to add that I want to keep the original .jpg files unchanged and store these tags in .jpg.xmp sidecar files.

Is this feasible as well ?

Brgds,
Michael
Title: Re: Parameters for creating [EXIF] DateTimeOriginal - tag
Post by: Phil Harvey on January 30, 2020, 07:49:39 AM
Hi Michael,

This gets more complicated, but here you go:

exiftool -addtagsfromfile @ -datetimeoriginal-= "-datetimeoriginal<filemodifydate" "-datetimeoriginal<createdate" -createdate-= "-createdate<filemodifydate" "-createdate<datetimeoriginal" -srcfile %d%f.%e.xmp -ext jpg FILESorDIRS

See example 13 here (https://exiftool.org/metafiles.html#EX13).

Lots of wiggle room here too.  This will add DateTimeOriginal to the XMP if it doesn't exist in the XMP.  I would have to think more about this if you want to add it to the XMP only if it doesn't exist in the JPG.

- Phil
Title: Re: Parameters for creating [EXIF] DateTimeOriginal - tag
Post by: Alan Clifford on January 30, 2020, 09:01:50 AM
Quote from: jojomimi on January 30, 2020, 07:41:22 AM

I forgot to add that I want to keep the original .jpg files unchanged and store these tags in .jpg.xmp sidecar files.

datetimeoriginal in exif is not the same field as datetimeoriginal in xmp.

Title: Re: Parameters for creating [EXIF] DateTimeOriginal - tag
Post by: Phil Harvey on January 30, 2020, 09:06:29 AM
Good Point.  In XMP, DateTimeOriginal is better copied to XMP-photoshop:DateCreated.  CreateDate is OK though, and should go to XMP-xmp:CreateDate.

- Phil
Title: Re: Parameters for creating [EXIF] DateTimeOriginal - tag
Post by: jojomimi on January 30, 2020, 02:02:16 PM
Great, it works !

This XMP has been generated :

<?xpacket begin='' id='W5M0MpCehiHzreSzNTczkc9d'?>
<x:xmpmeta xmlns:x='adobe:ns:meta/' x:xmptk='Image::ExifTool 10.80'>
<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/'>
  <exif:DateTimeOriginal>2018-01-04T11:51:14+01:00</exif:DateTimeOriginal>
</rdf:Description>

<rdf:Description rdf:about=''
  xmlns:xmp='http://ns.adobe.com/xap/1.0/'>
  <xmp:CreateDate>2018-01-04T11:51:14+01:00</xmp:CreateDate>
</rdf:Description>
</rdf:RDF>
</x:xmpmeta>
<?xpacket end='w'?>

Last question :

Can I make this command conditional ?  In some cases, my pictures already already contain this "CreateDate" tag (containing correct information !), how can I avoid overwriting this with the "FileModifyDate" tag (which is less reliable)?
Title: Re: Parameters for creating [EXIF] DateTimeOriginal - tag
Post by: Phil Harvey on January 30, 2020, 02:20:56 PM
What do you mean?  You won't be overwriting the CreateDate in your pictures because you are writing sidecar files, not the picture files.

- Phil
Title: Re: Parameters for creating [EXIF] DateTimeOriginal - tag
Post by: jojomimi on January 30, 2020, 02:41:05 PM
Indeed, sorry for the confusion, I mean :

In some cases, my XMP files (not pictures) already contain this "CreateDate" tag (containing correct information !), how can I avoid overwriting this with the "FileModifyDate" tag (which is less reliable) ?
Title: Re: Parameters for creating [EXIF] DateTimeOriginal - tag
Post by: Phil Harvey on January 30, 2020, 03:37:48 PM
The command I gave already does this.

- Phil
Title: Re: Parameters for creating [EXIF] DateTimeOriginal - tag
Post by: jojomimi on January 31, 2020, 03:56:07 AM
You're right Phil, it works !
Many, many thanks !
Brgds,
Michael