Open maximzasorin opened 8 months ago
Thanks for detailed bug report. I see the issue in the code. osxphotos sets IPTC:DateCreated
and EXIF:DateTimeOriginal
when using --exiftool
but it does not set XMP:DateCreated
or XMP:DateTimeOriginal
and apparently Photos is prioritizing these. I'll fix this as soon as I get a chance.
This will need to be fixed in the sidecar generation as well.
The problem appeared only in the edited file because Photos wrote the XMP tags when editing the file and osxphotos/exiftool did not overwrite these. The XMP tags were not present in the original so Photos defaulted to the EXIF or IPTC date.
I've not been able to reproduce this behavior. I've tested on macOS 13.6.1 and 14.0 and Photos does not appear to write the XMP fields that are shown in your example and thus the import works as expected -- the date is read from the EXIF data and is adjusted correctly in Photos.
Did you edit the photos in an external editor? Did you do any processing on the photos after the export?
Before I blindly fix something I cannot reproduce I want to ensure the correct date/time fields are being set by osxphotos and that I understand the behavior.
The mystery deepens. I tried manually setting each of the 3 XMP tags in your example but when I import into Photos, Photos uses the "correct" date that's in the EXIF data. Photos (at least on Ventura) does not appear to be reading the XMP dates. If you're able to share a sample image that is doing this, both original and exported, that would be helpful: osxphotos.py@gmail.com
Did you edit the photos in an external editor? Did you do any processing on the photos after the export?
No, I didn't edit the photo in an external editor, only through the built-in Photos editor. And no, I didn't process the photo after export.
If you're able to share a sample image that is doing this, both original and exported, that would be helpful
I've sent the files to the email.
***
Before I blindly fix something I cannot reproduce I want to ensure the correct date/time fields are being set by osxphotos and that I understand the behavior.
Yes, the issue is strange. I tried another random photo from the internet, and the issue did not repeat. Maybe this is some rare situation, I don't know, or maybe I miss something.
I received the sample files, thanks. I am able to replicate this behavior. Interestingly, I cannot get Photos to write the XMP:DateCreated
field but if this field is removed from your edited image, then Photos uses the correct date/time on import. If I set the XMP:DateCreated
to a new value and import the photo, Photos uses this new date/time.
Thus, I guess osxphotos should write XMP:DateCreated
, XMP:CreateDate
, and XMP:ModifyDate
to be consistent with what you're seeing from Photos. I do not have the most current version of Sonoma (only a VM running the beta) so I cannot test to see exactly what Photos is doing but it appears from the screencast you sent that Photos, sometime after 14.0.0 beta, is writing these XMP fields which it did not previously do.
Something weird is happening. If I change the XMP:DateCreated
on the photo you sent and import it, Photos uses the new date. If I add XMP:DateCreated
and/or XMP:CreateDate
to a photo from my library and import it, Photos uses the date in the EXIF field. There's more going on that just XMP data.
More testing and I am able to replicate that adding XMP:DateCreated
to a photo causes Photos to use this date on import. Not sure what happened before but I may have mistyped the exiftool command. So XMP:DateCreated
takes precedence over any other dates in the files. Photos appears to add XMP:CreateDate
and XMP:ModifyDate
but does not appear to read these.
osxphotos should probably write all 3 XMP date fields.
Note: unlike other exiftool date/time fields, these should be formatted as ISO 8601
I’m experiencing the same issue. Everything works perfectly, except for the ‘adjusted’ creation date, which is set to the exported date.
First of all, thanks for a great tool!
Describe the bug The
osxphotos export
command with the--exiftool
option does not always write the adjusted creation date of photo to meta tags. The adjusted creation date is not written if the photo was edited in the built-in Photos editor. However, the original file is exported correctly.How to reproduce
osxphotos export --exiftool
.I did a little research to give you more information.
I have a photo IMG_1244.JPG with a creation date of 2024-01-01, I import it into the Photos app in the normal way. Next, I change the creation date of the photo from 2024-01-01 to 2024-01-05 through the "Adjust date and time" in the Photos app and export the photo: ``` % osxphotos export --exiftool --uuid XXX ./exported ``` I expect that with `--exiftool` option it will write the adjusted creation date into the meta tags of the photo, and I can check the result with `exiftool`. Everything works as I expected, the date I adjust is written to the meta tags. Original file: ``` % exiftool -G -a ./IMG_1244.JPG | grep Date [File] File Modification Date/Time : 2024:01:09 20:29:39+03:00 [File] File Access Date/Time : 2024:01:09 21:07:10+03:00 [File] File Inode Change Date/Time : 2024:01:09 20:29:39+03:00 [EXIF] Modify Date : 2024:01:01 12:34:56 [EXIF] Date/Time Original : 2024:01:01 12:34:56 [EXIF] Create Date : 2024:01:01 12:34:56 [MakerNotes] Date Stamp Mode : Off ``` Exported file: ``` % exiftool -G -a ./exported/IMG_1244.JPG | grep Date [File] File Modification Date/Time : 2024:01:09 20:29:39+03:00 [File] File Access Date/Time : 2024:01:09 21:08:31+03:00 [File] File Inode Change Date/Time : 2024:01:09 21:08:30+03:00 [EXIF] Modify Date : 2024:01:05 12:34:56 [EXIF] Date/Time Original : 2024:01:05 12:34:56 [EXIF] Create Date : 2024:01:05 12:34:56 [MakerNotes] Date Stamp Mode : Off [IPTC] Date Created : 2024:01:05 [Composite] Date/Time Original : 2024:01:05 12:34:56+03:00 [Composite] Date/Time Created : 2024:01:05 12:34:56+03:00 ``` But it work differently with an edited photo. Next, I edit the same photo in the built-in Photos editor, for example, I crop the photo to the aspect ratio I want, and then export the same photo but to a new directory: ``` % osxphotos export --exiftool --uuid XXX ./exported2 ``` In the exported2 directory I get two files IMG_1244.JPG and IMG_1244_edited.jpeg, the results of running `exiftool` is as follows: ``` % exiftool -G -a ./exported2/IMG_1244.JPG | grep Date [File] File Modification Date/Time : 2024:01:09 20:29:39+03:00 [File] File Access Date/Time : 2024:01:09 21:12:48+03:00 [File] File Inode Change Date/Time : 2024:01:09 21:12:46+03:00 [EXIF] Modify Date : 2024:01:09 21:12:27 [EXIF] Date/Time Original : 2024:01:05 12:34:56 [EXIF] Create Date : 2024:01:05 12:34:56 [MakerNotes] Date Stamp Mode : Off [IPTC] Date Created : 2024:01:05 [Composite] Date/Time Original : 2024:01:05 12:34:56+03:00 [Composite] Date/Time Created : 2024:01:05 12:34:56+03:00 ``` ``` % exiftool -G -a ./exported2/IMG_1244_edited.jpeg | grep Date [File] File Modification Date/Time : 2024:01:09 21:12:28+03:00 [File] File Access Date/Time : 2024:01:09 21:12:47+03:00 [File] File Inode Change Date/Time : 2024:01:09 21:12:46+03:00 [EXIF] Modify Date : 2024:01:09 21:12:27 [EXIF] Date/Time Original : 2024:01:05 12:34:56 [EXIF] Create Date : 2024:01:05 12:34:56 [IPTC] Date Created : 2024:01:05 [XMP] Date Created : 2024:01:01 12:34:56 [XMP] Create Date : 2024:01:01 12:34:56 [XMP] Modify Date : 2024:01:01 12:34:56 [ICC_Profile] Profile Date Time : 2022:01:01 00:00:00 [Composite] Date/Time Original : 2024:01:05 12:34:56+03:00 [Composite] Date/Time Created : 2024:01:05 12:34:56+03:00 ``` The edited file (the one with the _edited suffix) has XMP meta tags that contain the original creation date of the photo, even though I used the `--exiftool` option when exporting. The "[XMP] Date Created" meta tag contains the date 2024-01-01 (original), and the "[IPTC] Date Created" contains the date 2024-01-05 (adjusted by me in Photos).Expected behavior I expect that the date I set via Photos will go into the edited photo during export with
osxphotos export --exiftool
, and if it is re-imported, the adjusted date will be used.I don't sure if this is the correct behavior or not, but XMP meta tags are added to the edited photo, which
osxphotos export
does not overwrite when exporting with the--exiftool
option. If I then import the file with the _edited suffix into Photos, the app identifies creation date of the photo from the XMP meta tag as 2024-01-01 and not as 2024-01-05.Desktop (please complete the following information):