The Mac version of Adobe Lightroom (LR) has a bug (some might call it a feature) which changes and updates the Mac OSX file "Creation date" to the current date/time whenever a keyword is added or changed. Fortunately those files can be fixed by copying the EXIF date back to the Creation date (until a new keyword is written to the file and the procedure has to be repeated).
LR geeks might only rely on the EXIF data for such info but I would like the Creation date to be correct as well. Exiftool to the rescue! I have a couple of script ideas but I need help with the actual commands, so how do I do the following?:
1) Read the date/time from the file's EXIF date tag (if available), then write it to the Mac OSX file "Creation date". If the EXIF date tag isn't available, skip the process for that file and move to the next one in the folder.
I understand there are several EXIF date tags (Date time original, Date time digitized and date time) but I don't know which one would be correct to read from. In LR I see they're all the same date/time for each photo.
2) For scanned images (usually not already having any EXIF date tag):
read the date/time from the Mac OSX file "Creation date" then create and write a new EXIF date tag.
Assuming the Creation date hasn't been mangled by LR already (I plan to use this script as part of the scanning process) the files should then have an EXIF date which can be used to re-write the (mangled by LR) file "Creation date" now and then.
Again I don't know which date tag would be best suited for this.
3) As an extra safety feature, add the date/time to the actual filename. I assume the best method would be to read it from an EXIF tag (and not the file "Creation date") as that would be stable. It should then skip any file without an EXIF date tag (again, not sure which date tag should be used) and name files in the following format: YYYYMMDD-HHMMSS_OriginalFilename.extension
If I recall, Exiftool can't directly change the creation date (FileCreateDate) on the mac (I'm not a mac user). If you check the note under FileCreateDate (https://exiftool.org/TagNames/Extra.html), it says
"Note that although ExifTool does not currently support FileCreateDate on other systems, the OS X file creation date may be accessed via the MDItemFSCreationDate tag when the MDItemTags API option is set, and may be written indirectly via the FileModifyDate tag by following these steps: 1. Rewrite the file to set the filesystem creation and modification times to the current time, 2. Set FileModifyDate to the desired creation time, then 3. Restore FileModifyDate to its original value)"
For scanned images, I think the appropriate tag would be CreateDate. The Exif spec calls this tag DateTimeDigitized. There's also an XMP:DateTimeDigitized tag but I would give priority to the exif tag.
Hopefully someone more mac aware can help out, since I'm unable to test out the specifics. There are a few other threads in this forum about Macs and creation date, so you might try searching through those to see if they can help.
Quote from: StarGeek on January 29, 2016, 04:22:37 PM
If I recall, Exiftool can't directly change the creation date (FileCreateDate) on the mac (I'm not a mac user). If you check the note under FileCreateDate (https://exiftool.org/TagNames/Extra.html), it says
"Note that although ExifTool does not currently support FileCreateDate on other systems, the OS X file creation date may be accessed via the MDItemFSCreationDate tag when the MDItemTags API option is set, and may be written indirectly via the FileModifyDate tag by following these steps: 1. Rewrite the file to set the filesystem creation and modification times to the current time, 2. Set FileModifyDate to the desired creation time, then 3. Restore FileModifyDate to its original value)"
I'm not sure what that means -if there's a way around the limitation or if it just won't overwrite the file "Creation date". If it won't, at least I have a nice drag & drop tool which will: A Better Finder Attributes (http://www.publicspace.net/ABetterFinderAttributes/) (using the "Copy EXIF timestamp to Creation date" preset action). Alas it's not scriptable which probably means I can't use it in conjuction with Exiftool so that I can have one script which does it all (IMHO simpler and more user friendly than having to remember several steps to do).
QuoteFor scanned images, I think the appropriate tag would be CreateDate. The Exif spec calls this tag DateTimeDigitized. There's also an XMP:DateTimeDigitized tag but I would give priority to the exif tag.
It's a bit confusing since all those three tags have the same time/date in my photos. But I tried out a demo of the Vuescan (http://www.hamrick.com/) (available for Mac, Windows and Linux) scanning software (improved scanning software over what comes with most scanners) and it creates what is displayed as "Date Time Digitized" in Lightroom. So I suppose that's the EXIF tag to go for.
QuoteHopefully someone more mac aware can help out, since I'm unable to test out the specifics. There are a few other threads in this forum about Macs and creation date, so you might try searching through those to see if they can help.
I've done some searching/browsing in the forum but most of it is a bit over my head.
Anyway, as Exiftool doesn't seem to be able to overwrite the OSX file "Creation date" I'll move on to what Exiftool can probably do. Can someone please tell me the commands for doing the following:
a) create a date/time EXIF tag if it isn't already there (typically scanned files) and copy the file Creation date over to it:
- CHECK if the file contains a date/time EXIF tag
- if YES, do nothing with the file (and move on to check the next file)
- if NO, READ the date/time info from the OSX file "Creation date" and WRITE a new EXIF date/time tag with that info
b) add the time/date to the file name:
- CHECK if the file contains a date/time EXIF tag
- if YES, READ the date/time from that tag, then WRITE it to the filename while keeping the existing filename using this format: YYYYMMDD-HHMMSS_originalfilename.extension
- if NO, do nothing with the file (and move on to check the next file)
c) Can Exiftool be used to find all files in a folder/sub-folders which DON'T contain any date/time EXIF tags and display them in the OSX Finder? That way I can further fix those files with the above procedure (step a). I would usually try this using the OSX Smart search feature with a suitable search criteria, but alas I can't find any EXIF date/time tags for that.
OK, I've gotten the following command line from someone else which I assumed would read the OSX File Creation date, then create an EXIF date/time tag in the file and writing the same date as in the OSX file Creation date. But it appears to read the OSX file Modification date instead:
exiftool -r '-alldates<FileModifyDate' -keywords+=DateModified -if '!$datetimeoriginal' . -overwrite_original
I'm guessing tag which needs changing is either FileModifyDate or DateModified (I really don't understand how the command sequence above works). Can someone point med in the right direction please?
Try FileCreateDate instead of FileModifyDate.
I think you mean ModifyDate instead of DateModified, as I can't find a tag with that name and trying to set it produces an error.
To add a tag to a keyword, you need to use +< instead of +=. The latter directly sets a value instead of copying a tag. In this case, you would end up with a Keyword of "DateModified"
Also, your command will set the keyword to the previous ModifyDate, not the value you are currently setting.
So try this command:
exiftool -r '-alldates<FileCreateDate' '-keywords+<FileCreateDate' -if '!$datetimeoriginal' . -overwrite_original
Thanks, but unfortunately I got loads of error messages (apparently one for each file) like this when I enter the commands (shown in bold) in the OSX Terminal:
$ cd folder_path_of_images_to_be_fixed
$ exiftool -r '-alldates<FileCreateDate' '-keywords+<FileCreateDate' -if '!$datetimeoriginal' . -overwrite_original
Warning: No writable tags set from ./filename1.jpg
(same error message repeated here for the rest of the 126 JPG files in the same folder)
1 directories scanned
0 image files updated
126 image files unchanged
$
So I'm a little confused about how this works, and why there's "keyword" mentioned here. Does the whole thing work by creating a NEW file which is a COPY of the original one, but this time with an EXIF date/time tag, so essentially the existing keywords I've added in the past to the file also needs to be copied over? And not as I previously thought; the image file gets MODIFIED by adding the date/time tag to the EXIF header?
Update: I noticed there being a couple of apostrophe characters surrounding some commands not used in the previous example (shown in red below):
exiftool -r '-alldates<FileCreateDate' '-keywords+<FileCreateDate' -if '!$datetimeoriginal' . -overwrite_original
I removed the apostrophes but got another error message instead, so obviously that didn't work either:
-bash: FileCreateDate: No such file or directory
Quote from: pacman on February 01, 2016, 05:52:58 PM
Update: I noticed there being a couple of apostrophe characters surrounding some commands not used in the previous example (shown in red below):
exiftool -r '-alldates<FileCreateDate' '-keywords+<FileCreateDate' -if '!$datetimeoriginal' . -overwrite_original
Yes, they are necessary to prevent the command line from treating it as a file redirection command.
As for the rest, I'm not sure what is the proper tag for you to use. Looking through the forum, FileCreateDate support on the Mac seems questionable, hopefully someone with Mac experience can weigh in.
Try using this command to see if you can see the file tag that has the proper date that you want to copy.
exiftool -system:time:all -s
This is strange, because I don't get the file Creation date at all by issuing that command:
$ exiftool -system:time:all -s path/filename.jpg
FileModifyDate : 2015:06:15 23:38:16+02:00
FileAccessDate : 2016:02:02 06:56:16+01:00
FileInodeChangeDate : 2016:02:02 06:55:54+01:00
$
... while doing a File-Get info in the OSX desktop Finder for the same file it says the file was created on March 29th 2015 (seen screenshot attachement). This is the date I want to transfer over to the newly created date/time EXIF tag.
I knew I had read something recent about Macs and creation date, but I only just found the thread (https://exiftool.org/forum/index.php?topic=6923.0). Previously Phil didn't have a way that he could get Exiftool to read a Macs FileCreateDate but he recently figured out a way.
Make sure you're running at least ExifTool v. 10.09 and try using MDItemContentCreationDate instead of FileCreateDate and see if that does what you want. Test it out first before running on a whole directory.
I've got version 10.10 installed.
If I've understood the changes correctly, the following did seem to work according to a quick test:
$ exiftool -r '-alldates<MDItemContentCreationDate' '-keywords+<MDItemContentCreationDate' -if '!$datetimeoriginal' . -overwrite_original
Warning: [minor] Creating non-standard EXIF in PNG - ./non-exif_CCF_2.png
Warning: [minor] Creating non-standard EXIF in PNG - ./Screen Shot 2016-01-18 at 11.47.35.png
1 directories scanned
6 image files updated
$
I'm not sure what is meant by "creating non-standard EXIF in PNG" -aren't PNG files supposed to have EXIF data in them or is it the command line above? In any case they didn't get any EXIF date/time tags. The other test files are JPG and TIFF which all seemed to work.
I also noticed that the time in the modified file is exactly 1 hour behind the original file.
Someone in a different forum suggested the following usage of exiftool to create
$ exiftool -r '-alldates<FileModifyDate' -keywords+=DateModified -if '!$datetimeoriginal' .
Warning: [minor] Creating non-standard EXIF in PNG - ./non-exif_CCF_2.png
Warning: [minor] Creating non-standard EXIF in PNG - ./Screen Shot 2016-01-18 at 11.47.35.png
1 directories scanned
6 image files updated
$ exiftool -delete_original -r .
1 directories scanned
6 image files found
6 originals will be deleted! Are you sure [y/n]? y
6 original files deleted
$ exiftool -restore_original .
1 directories scanned
6 image files found
0 original files found
$
I assume this is more or less the same thing, but here the date (compared to the original file's Creation date) is correct. Again the PNG files aren't getting any date/time EXIF tags though.
Quote from: pacman on February 02, 2016, 05:29:04 PM
I'm not sure what is meant by "creating non-standard EXIF in PNG" -aren't PNG files supposed to have EXIF data in them or is it the command line above? In any case they didn't get any EXIF date/time tags.
No, the PNG spec does not support EXIF data. Exiftool (and Exiv2 (http://www.exiv2.org/), I think) support a non-standard work around that allows adding EXIF data to PNGs. Other programs are unlikely to be able to read EXIF data added by Exiftool to a PNG file.
QuoteI also noticed that the time in the modified file is exactly 1 hour behind the original file.
No idea what might be happening there. You can try adding the
-P (http://www.exiftool.org/exiftool_pod.html#p) option, but again, I'm too ignorant of the Mac file system. You also might try
-overwrite_original_in_place (http://www.exiftool.org/exiftool_pod.html#overwrite_original_in_place).
QuoteSomeone in a different forum suggested the following usage of exiftool to create
<snip commands>
You can try
FileModifyDate and see if that works better for you. As I said before, I can find no data on a DateModified tag, which is why I suggested
ModifyDate.
The second command just deletes any backup files that are created when you run the command. You can avoid the creation of the backup files with
-overwrite_original or
-overwrite_original_in_place. The third command does nothing, as the backup files were deleted with the second command, note the "0 original files found" response. Neither of the last two commands will do anything to change the dates of the files.
I've tried lots of things now but the date differs (between the OSX file and EXIF dates) no matter what.
Could it have something to do with time zone settings, on my Mac or in the camera?
Actually I noticed that with some files the OSX file "Creation date" differs with -1 hour in the EXIF while others show -2 hours in the EXIF. It occured to me that it could have to do with the timezone, but the majority of images I'm testing with are scanned images, and of course there's no clock to adjust. And in my cameras I believe the time is set without any relation to another (i.e. timezone shift), so that doesn't make sense either.
I also tried scanning a document, set the Mac clock to a different timezone 7 hours ahead, scanned a new image, then set the time back on the Mac. I expected the OSX Creation dates to be vastly different but in fact the hours were exactly the same! Apparently the actual time isn't imprinted in the file but a time relative to the Mac's clock. I'm confused.... ???
Perhaps exiftool is doing it correctly and it's really an OS thing. Still I seem to recall that I did manage to create an exif date with it which gave the file the correct date (i.e. same as the OSX file date) but some I had some other issues with it (didn't copy the correct file date or something...).
Time issues aside, I understand that in most of the examples the OSX file modification date has been used as the date source and not the OSX file creation date. You mentioned some issues with the latter on this particular computer platform/OS, but I think I really should use the creation date which would be the date I scanned the image. Usually both creation and modification dates are the same, but I have seen instances where they're not, so I used "A Better Finder Attributes" to change the Creation and Modification dates, then see which date exiftool had used after creating the EXIF date/time tag and transferring the file date over to it. This is the command I ended up with which took the OSX file Creation date into the newly created EXIF date/time tag:
$ exiftool -r '-alldates<MDItemContentCreationDate' -if '!$datetimeoriginal' . -overwrite_original_in_place
I did get an error concerning the PNG file I had in that same folder. Upon issuing the above command it says:
Warning: [minor] Ignored empty rdf:Seq list for exif:ISOSpeedRatings - ./testimage.png
That PNG was actually a regular JPG from a camera (meaning it had all the necessary EXIF date tags to begin with) opened in OSX's Preview app, then "Save as" selecting the PNG format. Upon reopening the file I can clearly see the EXIF date tags present, like with the JPG file. And Lightroom also recognized the date, so it appears EXIF tags can be saved in them. The question of course is how to do with with PNG files not already having the EXIF date tag to start with.
UPDATE: I just compared the EXIF and file dates of some regular camera JPG images and they were consistent with the OSX file Creation and Modification dates, so it appears it's not an OS thing as far as I can see.
Sorry for the delay in responding.
Unfortunately the OSX MDItemFSCreationDate is in UTC. For example:
> exiftool a.jpg -MDItemFSCreationDate
MD Item FS Creation Date : 2016:02:05 16:34:27+0000
However, EXIF doesn't support a time zone. I'm not sure exactly what to suggest here. Perhaps ExifTool should be adjusting these MDItem date/time values to local time?
- Phil
Edit: I think I have convinced myself that local times would be more useful, so ExifTool 10.11 will convert UTC MDItem date/time values to local time, like this:
> exiftool a.jpg -MDItemFSCreationDate
MD Item FS Creation Date : 2016:02:05 11:34:27-05:00
Thanks for looking into this Phil.
Will that Exiftool update be available soon, and would converting the files with it enable the time to display correctly (i.e. same as the OSX file Creation date) within software such as Lightroom, in the same way as digital camera files have a consistency between the EXIF date tags and the OSX file Creation date?
My hope is that it will.
The new version is probably about a week away.
- Phil
Quote from: Phil Harvey on February 10, 2016, 10:03:49 PM
My hope is that it will.
The new version is probably about a week away.
Looking forward to that.
Will you considering also adding the ability to write the Mac OSX file "Creation date"?
I'm asking because in order to fix the OSX file Creation dates which Adobe Lightroom updates to "now" (every time a keyword is added) I now need to use A Better Finder Attributes (http://www.publicspace.net/ABetterFinderAttributes/index.html) (it reads the EXIF dates and copies that over to the OSX file Creation date).
Since I'm using Exiftool to read the OSX file Creation date, then create and write the previously non-existing date tags to scanned images it would be nice to use Exiftool for that too so that both processes can be used in the same script.
Quote from: pacman on February 14, 2016, 12:42:48 PM
Will you considering also adding the ability to write the Mac OSX file "Creation date"?
The mdls utility that I am using to extract this information does not have the write ability.
- Phil
I understand.
Do you know of any other command-line tool which could be used for that purpose, perhaps in conjunction with Exiftool?
UPDATE: I'm no UNIX expert (far from it) but it appears a command available in OSX called "xattr" might be what does this sort of thing according to its man file. If so, could it be used in conjunction with Exiftool so that the file creation date could be re-written?
Thanks for the suggestion, but the xattr man page specifically states:
The xattr command can be used to display, modify or remove the extended attributes of
one or more files, including directories and symbolic links. Extended attributes are
arbitrary metadata stored with a file, but separate from the filesystem attributes
(such as modification time or file size).
So it doesn't work on the filesystem attributes like FileCreateDate.
- Phil
Phil, the new version (10.11) seems to have fixed the date problems we talked about earlier in the thread. The dates are now consistent in LR and OSX according to some quick testing. Thanks for looking into that!
As for creating an EXIF date tag for image-files that don't have one already (scanned images, screenshots), then copying the OSX file "Creation" date over to that tag... I haven't quite gotten it right, even with version 10.11. Here's what I've tried with a folder containing just a JPG and a PNG file (both without any EXIF date tag):
$ exiftool -r '-alldates<MDItemContentCreationDate' -if '!$datetimeoriginal' . -overwrite_original_in_place
results:
- JPG file OK (newly created EXIF date tag based on OSX file "Creation" date). The OSX file and Lightroom dates are consistent now.
- PNG file appears to be unchanged (no EXIF date tag)
- OSX Finder observations: both files had their OSX File Modification dates changed to the current date/time. The OSX file Creation dates however were unchanged (which is good! This way I can skip the next "file-fixing" step which involves using A Better Finder Attributes to read the EXIF date, then write it to the OSX file Creation date).
$ exiftool -r '-alldates<MDItemContentCreationDate' '-keywords+<MDItemContentCreationDate' -if '!$datetimeoriginal' . -overwrite_original
results:
- JPG file OK (same as above)
- PNG still has no EXIF date tag (same as above)
- OSX Finder observations: both files had their OSX File Modification and Creation dates changed to the current date/time.
So it appears the first command works the best (as it leaves the OSX file Creation date alone and just changes the Modification date instead, which is perfect as backup software will identify the file as changed/modified (as it is, because it now contains an EXIF date tag) and therefore back up).
But how do I add an EXIF date tag to PNG files, and is "Date digitized" the correct one to use for this (while for digital camera images the "date original" should be used instead? ???
As for writing file-system attributes (such as giving Exiftool the ability to re-write the OSX file "Creation" date), someone suggested using the "touch" UNIX command taking the date variable from what Exiftool reads, then using "touch" with that variable to do the actual writing, using a Bash script. Does this sound like a solution?
From what I understand, the PNG spec doesn't allow for EXIF data. Exiftool has a workaround for this, which is also supported by Exiv2 and ImageMagick, but many other programs, such as Lightroom, do not.
Please tell me more about this workaround. I'm hoping Lightroom will still be able to recognize it.
I can't remember if I posted about it here, but I found that if I take a JPG (which already contains an EXIF date tag, either created from a digital camera or with the aid of Exiftool as discussed in this thread), then save it as a PNG file the EXIF date information will still be intact! Apart from seeing the date info using Mac OSX's "Preview" app I also tested it in Lightroom and indeed the date was present! The only difference between the original JPG and the PNG copy of it was that the JPG had a "Date time original" tag in Lightroom while the PNG didn't. They both had "Date time" and "Date time digitized" though.
Obviously I can't convert all my PNG files to JPG, add the EXIF date tag, save, then resave as a PNG, but it does seem that it's possible to give PNG files a date EXIF tag -my big question is how?
Quote from: pacman on February 28, 2016, 04:54:20 PM
Please tell me more about this workaround. I'm hoping Lightroom will still be able to recognize it.
I'm sure it's repeated somewhere on this site, but here (http://stackoverflow.com/a/24916466/3525475) is the stackoverflow post by Phil which is where I got the info.
As for the saving as PNG with data, you might try FAQ 3 (http://www.exiftool.org/faq.html#Q3) to figure out exactly where the data is being saved to.
Interesting.
So it says that PNG files can accept "chunks" of EXIF data. Does this mean that it will accept some EXIF tags but not the complete, standardized set? I wouldn't mind that as long as I get them to keep the EXIF dates.
You also mentioned some non-standardization for this which Lightroom among others won't accept, but is this referring to the above (missing the ability to keep a complete set of EXIF tags) or will added just the date tags also be in a non-standard format?
I found this Stackexchange page about EXIF dates in PNG files (http://photo.stackexchange.com/questions/64552/is-date-taken-exif-data-possible-on-png-file-and-is-it-possible-to-copy-dat) where among others, the following command should work:
exiftool -v "-PNG:CreationTime<FileModifyDate" -overwrite_original *
... which I understand should work for the Windows platform, and I'm guessing the Mac equivalent format would be:
exiftool -v '-PNG:CreationTime<MDItemContentCreationDate' -overwrite_original *
This didn't work any better though, and I've tried countless variations without success. Suggestions?
Quote from: pacman on March 02, 2016, 06:49:53 PM
So it says that PNG files can accept "chunks" of EXIF data. Does this mean that it will accept some EXIF tags but not the complete, standardized set? I wouldn't mind that as long as I get them to keep the EXIF dates.
The post I linked says exiftool stores "EXIF information in a PNG "Raw profile type APP1" zTXt chunk". This is non-standard and Exiftool will warn you as such when it first tries to add an EXIF tag to the png (
Warning: [minor] Creating non-standard EXIF in PNG).
QuoteYou also mentioned some non-standardization for this which Lightroom among others won't accept, but is this referring to the above (missing the ability to keep a complete set of EXIF tags) or will added just the date tags also be in a non-standard format?
It is a complete EXIF block and can even include things such as MakerNotes. But the PNG spec doesn't allow for the EXIF block. So it's not the EXIF block that's non-standard, it's the insertion of the EXIF block into the PNG which is non-standard.
QuoteI found this Stackexchange page about EXIF dates in PNG files (http://photo.stackexchange.com/questions/64552/is-date-taken-exif-data-possible-on-png-file-and-is-it-possible-to-copy-dat) where among others, the following command should work:
The original poster of that question had some misunderstandings of the data in question. They assumed "Date Taken" was an EXIF tag, when it is actually a file property that Windows derives from various tag in the file, similar to ExifTool's Composite tags. As I pointed out in that answer, they didn't want EXIF, they wanted a PNG TextualData tag (
PNG:CreationTime). That tag is not an EXIF tag.
One thing to remember is that what Lightroom calls a certain type of metadata may not be the actual name of that metadata. For example, one field that you can fill in on Lightroom is "Contact->Job Title" but the actual tags filled in are IPTC:By-lineTitle and XMP:AuthorsPosition. That's why I referred you to FAQ 3 (http://www.exiftool.org/faq.html#Q3) when you mentioned that when saved a file as a PNG, it had the data. It might be that Lightroom was saving it to a different tag.
I had a look at the Exiftool FAQ 3 which you pointed to and used the following command on a variety of files in order to analyze the metadata contents within:
exiftool -a -G1 -s FILENAME.PNG
All my test files had the following date info (the "xxxx" symbolizing the actual date/time) which I can only assume are the file dates that the OSX operating system has given them:
[System] FileModifyDate : xxxxxxxxxxxxx
[System] FileAccessDate : xxxxxxxxxxxxx
[System] FileInodeChangeDate : xxxxxxxxxxxxx
In a JPG however (from a digital camera) there were several additional date related tags as well which makes sense:
[IFD0] ModifyDate : xxxxxxxxxxxxx
[ExifIFD] DateTimeOriginal : xxxxxxxxxxxxx
[ExifIFD] CreateDate : xxxxxxxxxxxxx
[XMP-xmp] ModifyDate : xxxxxxxxxxxxx
[XMP-xmp] CreatorTool :
[XMP-xmp] CreateDate : xxxxxxxxxxxxx
[XMP-xmp] MetadataDate : xxxxxxxxxxxxx
[XMP-photoshop] DateCreated : xxxxxxxxxxxxx
[IPTC] DateCreated : xxxxxxxxxxxxx
[IPTC] TimeCreated : xxxxxxxxxxxxx
[Composite] DateTimeCreated : xxxxxxxxxxxxx
Moving on, looking at a screengrab (a Firefox extension which allows you to save a screenshot of an entire web page) there's very little additional info and no more date tags. Looking at an OSX screenshot however there are additional tags, mostly from its ICC profile, but again no dates. Same thing with a scanned image saved as a PNG.
But looking at a JPG (digital camera file) which has been opened (in OSX's "Preview" application) then re-saved as a PNG shows some interesting info (this file shows the date information to be embedded into the file) where the following date related tags are seen (in addition to the file related tags):
[XMP-photoshop] DateCreated : xxxxxxxxxxxxx
[XMP-xmp] CreateDate : xxxxxxxxxxxxx
[XMP-xmp] ModifyDate : xxxxxxxxxxxxx
So can these date tages be added to a PNG missing them to begin with, or is it only possible to get those metadata tags if you resave a JPG as mentioned above, as "leftovers" from the JPG file?
If the PNG image is missing date/time information, you can certainly use ExifTool to add it, but ExifTool can't create it from thin air -- you need to get it from somewhere.
- Phil
I was hoping to hear it's doable :)
Yes, the date info has to be gotten from somewhere, and I've already suggested in the start of this thread to read the OSX file "Creation" or "Created" date, then add it to the PNG file.
Based on earlier replies I assume the tag to read from would be either "FileCreateDate" (apparently only for Windows systems though) or "MDItemContentCreationDate", the latter as I understand it would be more applicable to Mac OSX systems. I also read (in the extra tags (https://exiftool.org/TagNames/Extra.html) section) about using the "MDItemFSCreationDate" tag for this, so I'm a little confused).
Sure. Then the command is something like this:
exiftool "-png:creationtime<mditemfscreationdate" some.png
- Phil
Thanks, but unfortunately it didn't work.
After running the PNG file through the command you suggested: (exiftool "-png:creationtime<mditemfscreationdate" some.png) I ended up with three additional tags compared to the original file when analyzing it (exiftool -a -G1 -s FILENAME.PNG):
[PNG] CreationTime : xxxxxxx
[XMP-exif] ExifImageWidth : xxxxxxx
[XMP-exif] ExifImageHeight : xxxxxxx
... but apparently this wasn't good enough for Preview nor Lightroom which wouldn't display any new metadata.
However I discovered something very interesting: Lightroom itself is able to add date metadata to files missing them! If possible I'd still want Exiftool to be able to do the same thing as it's more practical in a number of ways, but that discovery will hopefully help determine which tags need to be added in order to make this work. And Preview also displayed the date this time ("Date time original" under the Exif tab, and "Date time" under the TIFF tab -when "Tools"-Show inspector" is enabled), so fortunately it appears they haven't used proprietory tags either.
Comparing the Exiftool-processed file with the Lightroom-processed file ("Metadata"-"Edit capture time" menu, selecting "Change to file's creation date" and finally saving the metadata changes to the file) I found the following in the Lightroom processed file which weren't present in the one processed with Exiftool:
[XMP-exif] DateTimeOriginal : xxxxxxx
[XMP-tiff] Orientation : xxxxxxx
[XMP-xmpMM] DocumentID : xxxxxxx
[XMP-xmpMM] OriginalDocumentID : xxxxxxx
[XMP-xmpMM] InstanceID : xxxxxxx
[XMP-xmpMM] HistoryAction : xxxxxxx
[XMP-xmpMM] HistoryInstanceID : xxxxxxx
[XMP-xmpMM] HistoryWhen : xxxxxxx
[XMP-xmpMM] HistorySoftwareAgent : xxxxxxx
[XMP-xmpMM] HistoryChanged : xxxxxxx
[XMP-dc] Format : xxxxxxx
[XMP-photoshop] DateCreated : xxxxxxx
[XMP-xmp] ModifyDate : xxxxxxx
[XMP-xmp] MetadataDate : xxxxxxx
[XMP-crs] RawFileName : xxxxxxx
Comparing the above further with the JPG (from a digital camera) I analyzed earlier I see they both have the following tags in common, so I'm guessing one ([XMP-Photoshop] DateCreated) or all three have to be added by Exiftool for this to work:
[XMP-photoshop] DateCreated : xxxxxxx
[XMP-xmp] ModifyDate : xxxxxxx
[XMP-xmp] MetadataDate : xxxxxxx
UPDATE: I experimented a bit, figuring I should probably replace "-png" in the command with the XMP-EXIF tag. I tried exiftool "-XMP-Exif:DateTimeOriginal<MDitemfsCreationdate" some.png first, and success!! The "Exif" tab in Preview did indeed display a "Date time original" tag with the date, but the TIFF tab wasn't present. I'm not sure if that matters or not (I haven't tried the file in Lightroom nor analyzed it with the exiftool -a -G1 -s command, but I will), or even why it was present with the date converted files from Lightroom.
Quote from: pacman on March 08, 2016, 02:48:45 PM
Thanks, but unfortunately it didn't work.
After running the PNG file through the command you suggested: (exiftool "-png:creationtime<mditemfscreationdate" some.png) I ended up with three additional tags compared to the original file when analyzing it (exiftool -a -G1 -s FILENAME.PNG):
[PNG] CreationTime : xxxxxxx
[XMP-exif] ExifImageWidth : xxxxxxx
[XMP-exif] ExifImageHeight : xxxxxxx[
I find this hard to believe. This shouldn't happen, as the command is writing only a native PNG tag. Are you sure you didn't do something else? If you can reproduce this, send me the file and the exact command you used and I'll look into it. My email is philharvey66 at gmail.com
- Phil
You're absolutely right.
I must have been testing with some previously manipulated PNG files as I created some brand new PNG files, ran the command and found the only difference to be the addition of [PNG] CreationTime. Still, no date is displayed for the files using Preview.app in OSX.
Sorry about the confusion though.
Nevertheless I've tested a batch of PNG files with the various commands and sent your way. Fortunately Exiftool appears to be able to add an EXIF date tag to PNG files but the question is which one to add.
My concern was that ExifTool was behaving properly, which it was.
I don't have time to investigate the behaviour of other apps, but in general the support for metadata in PNG images tends to be sketchy at best. I am actually surprised that OS X supports XMP metadata in PNG, but according the descriptions you sent it seems that it does. So you should maybe be writing the standard XMP date/time tags (XMP-xmp:CreateDate, XMP-xmp:ModifyDate and XMP-photoshop:DateCreated) instead of the standard PNG tags as I used in my example command.
- Phil
I've just experimented with numerous tags which resulted in the following (the goal being to create a date/time tag in PNG files which didn't already have them, and have those recognized by Lightroom and in Mac OSX itself -using Preview):
$ exiftool "-XMP-xmpMM:HistoryWhen<MDItemContentCreationDate" FILENAME.PNG
Preview: failed (no date)
Lightroom: failed (no date)
$ exiftool "-XMP-xmp:MetadataDate<MDItemContentCreationDate" FILENAME.PNG
Preview: failed (no date)
Lightroom: failed (no date)
$ exiftool "-png:CreationTime<MDItemContentCreationDate" FILENAME.PNG
Preview: failed (no date)
Lightroom: failed (no date)
$ exiftool "-XMP-Exif:CreateDate<MDItemContentCreationDate" FILENAME.PNG
Error (tag 'xmp-exif:CreateDate' does not exist)
$ exiftool "-XMP-xmp:DateTimeDigitized<MDItemContentCreationDate" FILENAME.PNG
Error (tag 'xmp-xmp:DateTimeDigitized' does not exist)
$ exiftool "-XMP-Exif:DateTimeOriginal<MDItemContentCreationDate" FILENAME.PNG
Preview: yes "Date time original" (EXIF tab) added
Lightroom: yes "Date time original" (EXIF) added
Lightroom: yes "Date created" (IPTC) added
ABFA: yes -is able to restore the OSX creation date (reads the EXIF date in order to re-write the OSX file creation date)
$ exiftool "-XMP-xmp:ModifyDate<MDItemContentCreationDate" FILENAME.PNG
Preview: yes "Date time" (TIFF tab) added
Lightroom: yes "Date time" (EXIF) added
ABFA: yes -is able to restore the OSX creation date (reads the EXIF date in order to re-write the OSX file creation date)
$ exiftool "-XMP-photoshop:DateCreated<MDItemContentCreationDate" FILENAME.PNG
Preview: yes "Date time original" (EXIF tab) added
Lightroom: yes "Date created" (IPTC) added
ABFA: yes -is able to restore the OSX creation date (reads the EXIF date in order to re-write the OSX file creation date)
$ exiftool "-XMP-xmp:CreateDate<MDItemContentCreationDate" FILENAME.PNG
Preview: yes "Date time digitized" (EXIF tab) added
Lightroom: yes "Date time digitized" (EXIF) added
ABFA: failed -unable to restore OSX file creation date
$ exiftool "-XMP-Exif:DateTimeDigitized<MDItemContentCreationDate" FILENAME.PNG
Preview: yes "Date time digitized" (EXIF tab) added
Lightroom: yes "Date time digitized" (EXIF) added
ABFA: failed -unable to restore OSX file creation date
...and finally, in order to compare, using Lightroom's own "Change to file's creation date" feature....
This is obviously my reference (what I want to achieve) as the files naturally show their dates within Lightroom, but also in OSX itself.
- Preview: "Date time original" (EXIF tab) added
- Preview: "Date time" (TIFF tab) added
- Lightroom: "Date time original" added
- Lightroom: "Date time" (EXIF) added
- Lightroom: "Date time" (IPTC) added
- ABFA: yes -is able to restore the OSX creation date (reads the EXIF date in order to re-write the OSX file creation date)
Conclusion from the above tests:
The following two commands appear to give a PNG file the needed tags (using the Lightroom generated date feature as a reference):
$ exiftool "-XMP-Exif:DateTimeOriginal<MDItemContentCreationDate" FILENAME.PNG
Preview: adds "Date time original" (EXIF tab) date tag
Lightroom: adds "Date time original" (EXIF) date tag
Lightroom: adds "Date created" (IPTC) date tag
ABFA: yes -is able to restore the OSX creation date (reads the EXIF date in order to re-write the OSX file creation date)
and
$ exiftool "-XMP-xmp:ModifyDate<MDItemContentCreationDate" FILENAME.PNG
Preview: adds "Date time" (TIFF tab) date tag
Lightroom: adds "Date time" (EXIF) date tag
ABFA: yes -is able to restore the OSX creation date (reads the EXIF date in order to re-write the OSX file creation date)
The final solution... maybe
Having figured out the above I'm not entirely sure it's essential to combine the two commands as files with either command appear to work as intended. But if I want to make them appear as if Lightroom added a date tag to those PNG files (the only difference being that with the Exiftool processed files the "Date created" (IPTC) tag would contain an additional timezone number after the date (i.e. 2016-03-10T09:33:51+01:00 instead of 2016-03-10T09:33:51) then the procedure appeared to be as follows:
1) $ exiftool "-XMP-Exif:DateTimeOriginal<MDItemContentCreationDate" FILENAME.PNG
2) run ABFA on the file in order to restore the OSX file creation date. Failing to do this would also fail getting the correct "Date time" date tag as it's getting its info from the file creation date (which would be changed in step 1)
3) $ exiftool "-XMP-xmp:ModifyDate<MDItemContentCreationDate" FILENAME.PNG
Is there a way I can combine both command lines in a single line?
I'm hoping there will be a way for Exiftool to re-write the OSX file creation date (I've posted about this in a separate thread suggesting the use of the "touch" command) but until then I'll be using A Better Finder Attributes (ABFA) which does the job.
Quote from: pacman on March 13, 2016, 04:32:06 PM
1) $ exiftool "-XMP-Exif:DateTimeOriginal<MDItemContentCreationDate" FILENAME.PNG
2) run ABFA on the file in order to restore the OSX file creation date. Failing to do this would also fail getting the correct "Date time" date tag as it's getting its info from the file creation date (which would be changed in step 1)
3) $ exiftool "-XMP-xmp:ModifyDate<MDItemContentCreationDate" FILENAME.PNG
Is there a way I can combine both command lines in a single line?
Yes. You can copy as many tags as you want in a single command.
Also, you may want to add
-P -overwrite_original_in_place to preserve as many of the system attributes as possible.
- Phil
Thanks -that's a good point.
Experimenting a bit I came up with the following which appears to work with a folder with various files and file-types, some missing and some already containing EXIF date tags. Can you confirm if the syntax looks correct and won't touch files already containing EXIF date tags?
$ exiftool -r "-XMP-Exif:DateTimeOriginal<MDItemContentCreationDate" "-XMP-xmp:ModifyDate<MDItemContentCreationDate" -P -overwrite_original_in_place .
Actually it even keeps the OSX file creation date so I don't need to run the file(s) through ABFA afterwards unless Lightroom is used to add new keywords etc. :)
The syntax is good, but I don't understand why you think it shouldn't touch files already containing EXIF date tags, because it will. To do this, you could add something like: -if 'not $exif:datetimeoriginal'
- Phil
Because I read (or mis-read) [page]=3#topic-reply-list]here (page 3) (https://feedback.photoshop.com/photoshop_family/topics/bug_report_lightroom_changes_creation_date_of_image_files?topic-reply-list%5Bsettings) that Exiftool wouldn't do anything to files already having an EXIF date tag to begin with:
QuoteOpen terminal (make sure you have Exiftool installed)
and CD to your target directory.
Then copy & paste into the command line:
exiftool -r -overwrite_original_in_place '-datetimeoriginal<filemodifydate' -if '(not $datetimeoriginal or ($datetimeoriginal eq "0000:00:00 00:00:00")) and ($filetype eq "TIFF")' .
The period at the end's important. This will update every tiff in the folder so that the creation date is loaded into the metadata, if the image didn't have anything there to start with. If it did, it won't touch it. It will update your creation date to "now" though, so you'll have to go back through with something like "Finder Attirbutes' to reset the creation dates based on the exif data. (Reasoning, comma circular, see Circular Reasoning.) But it works.
If you want to get JPG,s just change the filetype to "JPG". PNG works too.
Anyway, after including the command in your previous posting it all appears to work fine (image files already containing an EXIF date aren't modified, non-image files are skipped and any image file without EXIF dates (including PNG files) get new EXIF date tags created based on the OSX file creation date), the final command being:
$
exiftool -r "-XMP-Exif:DateTimeOriginal<MDItemContentCreationDate" "-XMP-xmp:ModifyDate<MDItemContentCreationDate" -P -overwrite_original_in_place -if 'not $exif:datetimeoriginal' .Eventually I'll be making a "drag & drop" script placed in the OSX dock so I can quickly and easily add EXIF date tags to any file or folder I suspect is missing them.
But there's a strange thing happening with a couple of my PNG files: after being processed by Exiftool they still don't show up with any dates in the Preview app (while other PNGs do). Oddly all looks fine in Lightroom (the date has indeed been added as with the normal PNG files previously missing EXIF date tags).
However, if I add (and save) a keyword within Lightroom those "stubborn" files now show their dates in Preview as well!
So I found it obvious to compare the files' tags using
exiftool -a -G1 -s FILENAME.PNG, and that's what I did.
I found a "normal" PNG file to contain numerous
additional tags to start with (before being processed by Exiftool) compared to the "stubborn" PNG's tags, and after Exiftool-processing they both contained (as expected, based on my Exiftool command) the following new tags:
[XMP-exif] DateTimeOriginal
[XMP-xmp] ModifyDate
... in addition to this the "stubborn" PNG also had the following tag which was't present to begin with (but already present in the "normal" PNG, though with a different value). I assume it's just a standardized tag which any EXIF-manipulating software has to include. Didn't make any difference in showing the EXIF date in Preview though:
[XMP-x] XMPToolkit
... so the next step would be to see which additional tags were added to the "stubborn" PNG after Lightroom added a keyword to the file:
[XMP-exif] ExifVersion
[XMP-xmp] MetadataDate
[XMP-photoshop] DateCreated
[XMP-tiff] Orientation
[XMP-xmpMM] DocumentID
[XMP-xmpMM] OriginalDocumentID
[XMP-xmpMM] InstanceID
[XMP-xmpMM] HistoryAction
[XMP-xmpMM] HistoryInstanceID
[XMP-xmpMM] HistoryWhen
[XMP-xmpMM] HistorySoftwareAgent : Adobe Photoshop Lightroom 5.7.1 (Macintosh)
[XMP-xmpMM] HistoryChanged
[XMP-dc] Format
[XMP-dc] Subject
[XMP-crs] RawFileName
[XMP-lr] HierarchicalSubject
.... none of those tags were found in the "normal" PNG file to begin with though, so at this stage I'm thinking that one or several of those tags the "normal" PNG already came with might be the one(s) responsible for turning on/off Preview's ability to display the EXIF date or not:
[ICC-view] ViewingCondIlluminant
[ICC-view] ViewingCondSurround
[ICC-view] ViewingCondIlluminantType
[ICC-meas] MeasurementObserver
[ICC-meas] MeasurementBacking
[ICC-meas] MeasurementGeometry
[ICC-meas] MeasurementFlare
[ICC-meas] MeasurementIlluminant
[ICC-header] ProfileCMMType
[ICC-header] ProfileVersion
[ICC-header] ProfileClass
[ICC-header] ColorSpaceData
[ICC-header] ProfileConnectionSpace
[ICC-header] ProfileDateTime
[ICC-header] ProfileFileSignature
[ICC-header] PrimaryPlatform
[ICC-header] CMMFlags
[ICC-header] DeviceManufacturer
[ICC-header] DeviceModel
[ICC-header] DeviceAttributes
[ICC-header] RenderingIntent
[ICC-header] ConnectionSpaceIlluminant
[ICC-header] ProfileCreator
[ICC-header] ProfileID
[ICC_Profile] ProfileCopyright
[ICC_Profile] ProfileDescription
[ICC_Profile] MediaWhitePoint
[ICC_Profile] MediaBlackPoint
[ICC_Profile] RedMatrixColumn
[ICC_Profile] GreenMatrixColumn
[ICC_Profile] BlueMatrixColumn
[ICC_Profile] DeviceMfgDesc
[ICC_Profile] DeviceModelDesc
[ICC_Profile] ViewingCondDesc
[ICC_Profile] Luminance
[ICC_Profile] Technology
[ICC_Profile] RedTRC
[ICC_Profile] GreenTRC
[ICC_Profile] BlueTRC
[ICC-view] ViewingCondIlluminant
[ICC-view] ViewingCondSurround
[ICC-view] ViewingCondIlluminantType
[ICC-meas] MeasurementObserver
[ICC-meas] MeasurementBacking
[ICC-meas] MeasurementGeometry
[ICC-meas] MeasurementFlare
[ICC-meas] MeasurementIlluminant
[PNG] ProfileName
.... I assume the only way to figure this out is to add each of these tags, one at a time, to the "stubborn" PNG and see which one enables Preview to display the EXIF date tag.
I'm having a little trouble figuring out the correct syntax of adding a tag though. Having read through several examples I found this to be the way to do it: $ exiftool "TAG_GROUP:TAGNAME:VALUE" FILENAME.PNG which appeared to work when adding for instance the
XMP-x:XMPToolKit tag:
$
exiftool "-XMP-x:XMPToolKit=XMP Core 5.4.0" FILENAME.PNG.. but adding
PNG:ProfileName didn't work:
$
exiftool "-PNG:ProfileName=ICC Profile" FILENAME.PNGWarning: Tag 'PNG:ProfileName' does not exist
Nothing to do
.... what is the correct syntax for adding tags as the above doesn't work (while clearly present in one of the files after analysing it with
exiftool -a -G1 -s FILENAME.PNG)?
Quote from: pacman on March 19, 2016, 09:28:46 AM
Because I read
Quote
exiftool -r -overwrite_original_in_place '-datetimeoriginal<filemodifydate' -if '(not $datetimeoriginal or ($datetimeoriginal eq "0000:00:00 00:00:00")) and ($filetype eq "TIFF")' .
Right. This is because of the
-if condition, just like I suggested earlier.
QuoteI'm having a little trouble figuring out the correct syntax of adding a tag though.
Adding a tag is just like writing a tag. ExifTool will add it if it doesn't exist.
Quote.. but adding PNG:ProfileName didn't work:
Right. See the PNG tags documentation (https://exiftool.org/TagNames/PNG.html) for the reason.
- Phil
I see what you mean about the PNG tags (many which are not writeable with Exiftool).
Since I've tried to add just about all the other writeable tags to the file but still not getting Preview to display its time/date I can only assume that Lightroom adds some of the PNG tags which Exiftool can't write (but Lightroom can) that are essential to Preview.
Nevertheless, this is merely a frustration because it's just that I can't use Preview to quickly determine if a certain PNG file has its date or not embedded into the EXIF header. Perhaps I could create a drag & drop script for just that purpose using exiftool -a -G1 -s FILENAME.PNG (or look into another exiftool command which will just display the EXIF time/date if available, or alert that it's not there).
And when I'm done adding time/date to all the files' EXIF headers I'll be saving the metadata to the files in Lightroom anyway which will in turn let the time/date show when viewed in Preview, so it's really just an intermediate problem/frustration ;)
So what's left of the whole Lightroom puzzle now is to figure out a way to use Exiftool together with another command-line tool allowing the correct file date to be rewritten... Failing that there's always A Better Finder Attributes.