News:

2023-03-15 Major improvements to the new Geolocation feature

Main Menu

Fixing Lightroom messed up files with Exiftool (Mac)

Started by pacman, January 29, 2016, 04:00:49 PM

Previous topic - Next topic

pacman

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

Phil Harvey

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

pacman

#17
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?

Phil Harvey

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

pacman

#19
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?

StarGeek

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

pacman

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?

StarGeek

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 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 to figure out exactly where the data is being saved to.
* 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).

pacman

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 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?


StarGeek

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

pacman

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?



Phil Harvey

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

pacman

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 section) about using the "MDItemFSCreationDate" tag for this, so I'm a little confused).

Phil Harvey

Sure.  Then the command is something like this:

exiftool "-png:creationtime<mditemfscreationdate" some.png

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

pacman

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