Updated --exiftool to set dates/times as Photos does, issue #247

This commit is contained in:
Rhet Turnbull
2020-10-31 22:11:00 -07:00
parent fd14242022
commit 11459d1da4
5 changed files with 88 additions and 41 deletions

View File

@@ -2632,16 +2632,21 @@ def test_export_sidecar_keyword_template():
json_expected = json.loads(
"""
[{"_CreatedBy": "osxphotos, https://github.com/RhetTbull/osxphotos",
"EXIF:ImageDescription": "Girl holding pumpkin",
"XMP:Description": "Girl holding pumpkin",
"XMP:Title": "I found one!",
"XMP:TagsList": ["Kids", "Multi Keyword", "Test Album", "Pumpkin Farm"],
"IPTC:Keywords": ["Kids", "Multi Keyword", "Test Album", "Pumpkin Farm"],
"XMP:PersonInImage": ["Katie"],
"XMP:Subject": ["Kids", "Katie"],
"EXIF:DateTimeOriginal": "2018:09:28 16:07:07",
"EXIF:OffsetTimeOriginal": "-04:00"}]"""
[{"_CreatedBy": "osxphotos, https://github.com/RhetTbull/osxphotos",
"EXIF:ImageDescription": "Girl holding pumpkin",
"XMP:Description": "Girl holding pumpkin",
"XMP:Title": "I found one!",
"XMP:TagsList": ["Kids", "Multi Keyword", "Pumpkin Farm", "Test Album"],
"IPTC:Keywords": ["Kids", "Multi Keyword", "Pumpkin Farm", "Test Album"],
"XMP:PersonInImage": ["Katie"],
"XMP:Subject": ["Kids", "Katie"],
"EXIF:DateTimeOriginal": "2018:09:28 16:07:07",
"EXIF:CreateDate": "2018:09:28 16:07:07",
"EXIF:OffsetTimeOriginal": "-04:00",
"IPTC:DigitalCreationDate": "2018:09:28",
"IPTC:DateCreated": "2018:09:28",
"EXIF:ModifyDate": "2018:09:28 16:07:07"}]
"""
)[0]
with open("Pumkins2.jpg.json", "r") as json_file:

View File

@@ -67,18 +67,21 @@ XMP_FILENAME = "Pumkins1.jpg.xmp"
XMP_JPG_FILENAME = "Pumkins1.jpg"
EXIF_JSON_UUID = UUID_DICT["has_adjustments"]
EXIF_JSON_EXPECTED = (
'[{"_CreatedBy": "osxphotos, https://github.com/RhetTbull/osxphotos", '
'"EXIF:ImageDescription": "Bride Wedding day", '
'"XMP:Description": "Bride Wedding day", '
'"XMP:TagsList": ["wedding"], '
'"IPTC:Keywords": ["wedding"], '
'"XMP:PersonInImage": ["Maria"], '
'"XMP:Subject": ["wedding", "Maria"], '
'"EXIF:DateTimeOriginal": "2019:04:15 14:40:24", '
'"EXIF:OffsetTimeOriginal": "-04:00", '
'"EXIF:ModifyDate": "2019:07:27 17:33:28"}]'
)
EXIF_JSON_EXPECTED = """
[{"_CreatedBy": "osxphotos, https://github.com/RhetTbull/osxphotos",
"EXIF:ImageDescription": "Bride Wedding day",
"XMP:Description": "Bride Wedding day",
"XMP:TagsList": ["wedding"],
"IPTC:Keywords": ["wedding"],
"XMP:PersonInImage": ["Maria"],
"XMP:Subject": ["wedding", "Maria"],
"EXIF:DateTimeOriginal": "2019:04:15 14:40:24",
"EXIF:CreateDate": "2019:04:15 14:40:24",
"EXIF:OffsetTimeOriginal": "-04:00",
"IPTC:DigitalCreationDate": "2019:04:15",
"IPTC:DateCreated": "2019:04:15",
"EXIF:ModifyDate": "2019:07:27 17:33:28"}]
"""
def test_export_1():
@@ -507,7 +510,10 @@ def test_exiftool_json_sidecar_keyword_template_long(caplog):
"XMP:PersonInImage": ["Maria"],
"XMP:Subject": ["wedding", "Maria"],
"EXIF:DateTimeOriginal": "2019:04:15 14:40:24",
"EXIF:CreateDate": "2019:04:15 14:40:24",
"EXIF:OffsetTimeOriginal": "-04:00",
"IPTC:DigitalCreationDate": "2019:04:15",
"IPTC:DateCreated": "2019:04:15",
"EXIF:ModifyDate": "2019:07:27 17:33:28"}]
"""
)[0]
@@ -552,9 +558,12 @@ def test_exiftool_json_sidecar_keyword_template():
"XMP:TagsList": ["wedding", "Folder1/SubFolder2/AlbumInFolder", "I have a deleted twin"],
"IPTC:Keywords": ["wedding", "Folder1/SubFolder2/AlbumInFolder", "I have a deleted twin"],
"XMP:PersonInImage": ["Maria"],
"XMP:Subject": ["wedding", "Maria"],
"XMP:Subject": ["wedding", "Maria"],
"EXIF:DateTimeOriginal": "2019:04:15 14:40:24",
"EXIF:CreateDate": "2019:04:15 14:40:24",
"EXIF:OffsetTimeOriginal": "-04:00",
"IPTC:DigitalCreationDate": "2019:04:15",
"IPTC:DateCreated": "2019:04:15",
"EXIF:ModifyDate": "2019:07:27 17:33:28"}]
"""
)[0]
@@ -609,11 +618,15 @@ def test_exiftool_json_sidecar_use_persons_keyword():
"XMP:Description": "Girls with pumpkins",
"XMP:Title": "Can we carry this?",
"XMP:TagsList": ["Kids", "Suzy", "Katie"],
"IPTC:Keywords": ["Kids", "Suzy", "Katie"],
"XMP:PersonInImage": ["Suzy", "Katie"],
"XMP:Subject": ["Kids", "Suzy", "Katie"],
"IPTC:Keywords": ["Kids", "Suzy", "Katie"],
"XMP:PersonInImage": ["Suzy", "Katie"],
"XMP:Subject": ["Kids", "Suzy", "Katie"],
"EXIF:DateTimeOriginal": "2018:09:28 15:35:49",
"EXIF:OffsetTimeOriginal": "-04:00"}]
"EXIF:CreateDate": "2018:09:28 15:35:49",
"EXIF:OffsetTimeOriginal": "-04:00",
"IPTC:DigitalCreationDate": "2018:09:28",
"IPTC:DateCreated": "2018:09:28",
"EXIF:ModifyDate": "2018:09:28 15:35:49"}]
"""
)[0]
@@ -652,7 +665,11 @@ def test_exiftool_json_sidecar_use_albums_keyword():
"XMP:PersonInImage": ["Suzy", "Katie"],
"XMP:Subject": ["Kids", "Suzy", "Katie"],
"EXIF:DateTimeOriginal": "2018:09:28 15:35:49",
"EXIF:OffsetTimeOriginal": "-04:00"}]
"EXIF:CreateDate": "2018:09:28 15:35:49",
"EXIF:OffsetTimeOriginal": "-04:00",
"IPTC:DigitalCreationDate": "2018:09:28",
"IPTC:DateCreated": "2018:09:28",
"EXIF:ModifyDate": "2018:09:28 15:35:49"}]
"""
)[0]

View File

@@ -45,17 +45,23 @@ UUID_DICT = {
"xmp": "8SOE9s0XQVGsuq4ONohTng",
}
EXIF_JSON_EXPECTED = (
'[{"_CreatedBy": "osxphotos, https://github.com/RhetTbull/osxphotos", '
'"XMP:Title": "St. James\'s Park", "XMP:TagsList": ["UK", "England", '
'"London", "United Kingdom", "London 2018", "St. James\'s Park"], '
'"IPTC:Keywords": ["UK", "England", "London", "United Kingdom", "London 2018", '
'"St. James\'s Park"], "XMP:Subject": ["UK", "England", "London", "United Kingdom", '
'"London 2018", "St. James\'s Park"], "EXIF:GPSLatitude": 51.50357167, '
'"EXIF:GPSLongitude": -0.1318055, "EXIF:GPSLatitudeRef": "N", '
'"EXIF:GPSLongitudeRef": "W", "EXIF:DateTimeOriginal": "2018:10:13 09:18:12", '
'"EXIF:OffsetTimeOriginal": "-04:00", "EXIF:ModifyDate": "2019:12:01 11:43:45"}]'
)
EXIF_JSON_EXPECTED = """
[{"_CreatedBy": "osxphotos, https://github.com/RhetTbull/osxphotos",
"XMP:Title": "St. James\'s Park",
"XMP:TagsList": ["UK", "England", "London", "United Kingdom", "London 2018", "St. James\'s Park"],
"IPTC:Keywords": ["UK", "England", "London", "United Kingdom", "London 2018", "St. James\'s Park"],
"XMP:Subject": ["UK", "England", "London", "United Kingdom", "London 2018", "St. James\'s Park"],
"EXIF:GPSLatitude": 51.50357167,
"EXIF:GPSLongitude": -0.1318055,
"EXIF:GPSLatitudeRef": "N",
"EXIF:GPSLongitudeRef": "W",
"EXIF:DateTimeOriginal": "2018:10:13 09:18:12",
"EXIF:CreateDate": "2018:10:13 09:18:12",
"EXIF:OffsetTimeOriginal": "-04:00",
"IPTC:DigitalCreationDate": "2018:10:13",
"IPTC:DateCreated": "2018:10:13",
"EXIF:ModifyDate": "2019:12:01 11:43:45"}]
"""
def test_export_1():