diff --git a/osxphotos/photoinfo/photoinfo.py b/osxphotos/photoinfo/photoinfo.py
index debe12bf..a29c6329 100644
--- a/osxphotos/photoinfo/photoinfo.py
+++ b/osxphotos/photoinfo/photoinfo.py
@@ -68,11 +68,9 @@ class PhotoInfo:
@property
def filename(self):
""" filename of the picture """
- # sourcery off
- if self.has_raw and self.raw_original:
- # return name of the RAW file
- # TODO: not yet implemented
- return self._info["filename"]
+ if self._db._db_version <= _PHOTOS_4_VERSION and self.has_raw and self.raw_original:
+ # return the JPEG version as that's what Photos 5+ does
+ return self._info["raw_pair_info"]["filename"]
else:
return self._info["filename"]
@@ -80,7 +78,11 @@ class PhotoInfo:
def original_filename(self):
""" original filename of the picture
Photos 5 mangles filenames upon import """
- return self._info["originalFilename"]
+ if self._db._db_version <= _PHOTOS_4_VERSION and self.has_raw and self.raw_original:
+ # return the JPEG version as that's what Photos 5+ does
+ return self._info["raw_pair_info"]["originalFilename"]
+ else:
+ return self._info["originalFilename"]
@property
def date(self):
@@ -117,13 +119,32 @@ class PhotoInfo:
return photopath # path would be meaningless until downloaded
if self._db._db_version <= _PHOTOS_4_VERSION:
- vol = self._info["volume"]
- if vol is not None:
- photopath = os.path.join("/Volumes", vol, self._info["imagePath"])
- else:
- photopath = os.path.join(
- self._db._masters_path, self._info["imagePath"]
+ if self._info["has_raw"]:
+ # return the path to JPEG even if RAW is original
+ vol = (
+ self._db._dbvolumes[self._info["raw_pair_info"]["volumeId"]]
+ if self._info["raw_pair_info"]["volumeId"] is not None
+ else None
)
+ if vol is not None:
+ photopath = os.path.join(
+ "/Volumes", vol, self._info["raw_pair_info"]["imagePath"]
+ )
+ else:
+ photopath = os.path.join(
+ self._db._masters_path,
+ self._info["raw_pair_info"]["imagePath"],
+ )
+ else:
+ vol = self._info["volume"]
+ if vol is not None:
+ photopath = os.path.join(
+ "/Volumes", vol, self._info["imagePath"]
+ )
+ else:
+ photopath = os.path.join(
+ self._db._masters_path, self._info["imagePath"]
+ )
self._path = photopath
return photopath
@@ -507,9 +528,13 @@ class PhotoInfo:
for example: public.jpeg or com.apple.quicktime-movie
"""
if self._db._db_version <= _PHOTOS_4_VERSION:
- return (
- self._info["UTI_edited"] if self.hasadjustments else self._info["UTI"]
- )
+ if self.hasadjustments:
+ return self._info["UTI_edited"]
+ elif self.has_raw and self.raw_original:
+ # return UTI of the non-raw image to match Photos 5+ behavior
+ return self._info["raw_pair_info"]["UTI"]
+ else:
+ return self._info["UTI"]
else:
return self._info["UTI"]
diff --git a/osxphotos/photosdb/photosdb.py b/osxphotos/photosdb/photosdb.py
index ed7b5a05..30116091 100644
--- a/osxphotos/photosdb/photosdb.py
+++ b/osxphotos/photosdb/photosdb.py
@@ -846,7 +846,8 @@ class PhotosDB:
RKMaster.height,
RKMaster.width,
RKMaster.orientation,
- RKMaster.fileSize
+ RKMaster.fileSize,
+ RKVersion.subType
FROM RKVersion, RKMaster
WHERE RKVersion.masterUuid = RKMaster.uuid"""
)
@@ -873,7 +874,8 @@ class PhotosDB:
RKMaster.height,
RKMaster.width,
RKMaster.orientation,
- RKMaster.originalFileSize
+ RKMaster.originalFileSize,
+ RKVersion.subType
FROM RKVersion, RKMaster
WHERE RKVersion.masterUuid = RKMaster.uuid"""
)
@@ -919,6 +921,7 @@ class PhotosDB:
# 37 RKMaster.width,
# 38 RKMaster.orientation,
# 39 RKMaster.originalFileSize
+ # 40 RKVersion.subType
for row in c:
uuid = row[0]
@@ -1062,10 +1065,20 @@ class PhotosDB:
self._dbphotos[uuid]["cloudAvailable"] = None
self._dbphotos[uuid]["incloud"] = None
- # TODO: NOT YET USED -- PLACEHOLDER for RAW processing (currently only in _process_database5)
# original resource choice (e.g. RAW or jpeg)
- self._dbphotos[uuid]["original_resource_choice"] = None
- self._dbphotos[uuid]["raw_is_original"] = None
+ # In Photos 5+, original_resource_choice set from:
+ # ZADDITIONALASSETATTRIBUTES.ZORIGINALRESOURCECHOICE
+ # = 0 if jpeg is selected as "original" in Photos (the default)
+ # = 1 if RAW is selected as "original" in Photos
+ # RKVersion.subType, RAW always appears to be 16
+ # 4 = mov
+ # 16 = RAW
+ # 32 = JPEG
+ # 64 = TIFF
+ # 2048 = PNG
+ # 32768 = HIEC
+ self._dbphotos[uuid]["original_resource_choice"] = 1 if row[40] == 16 else 0
+ self._dbphotos[uuid]["raw_is_original"] = True if row[40] == 16 else False
# associated RAW image info
self._dbphotos[uuid]["has_raw"] = True if row[25] == 7 else False
@@ -1107,7 +1120,8 @@ class PhotosDB:
RKMaster.modelID,
RKMaster.fileSize,
RKMaster.isTrulyRaw,
- RKMaster.alternateMasterUuid
+ RKMaster.alternateMasterUuid,
+ RKMaster.filename
FROM RKMaster
"""
)
@@ -1123,6 +1137,7 @@ class PhotosDB:
# 7 RKMaster.fileSize,
# 8 RKMaster.isTrulyRaw,
# 9 RKMaster.alternateMasterUuid
+ # 10 RKMaster.filename
for row in c:
uuid = row[0]
@@ -1137,6 +1152,7 @@ class PhotosDB:
info["fileSize"] = row[7]
info["isTrulyRAW"] = row[8]
info["alternateMasterUuid"] = row[9]
+ info["filename"] = row[10]
self._dbphotos_master[uuid] = info
# get details needed to find path of the edited photos
@@ -1336,6 +1352,12 @@ class PhotosDB:
raw_uuid = info["raw_master_uuid"]
info["raw_info"] = self._dbphotos_master[raw_uuid]
info["UTI_raw"] = self._dbphotos_master[raw_uuid]["UTI"]
+ non_raw_uuid = info["non_raw_master_uuid"]
+ info["raw_pair_info"] = self._dbphotos_master[non_raw_uuid]
+ else:
+ info["raw_info"] = None
+ info["UTI_raw"] = None
+ info["raw_pair_info"] = None
# done with the database connection
conn.close()
diff --git a/tests/Test-10.14.6.photoslibrary/database/RKVersion_searchIndexText.skindex b/tests/Test-10.14.6.photoslibrary/database/RKVersion_searchIndexText.skindex
index dfe3a8a6..2ae017ba 100644
Binary files a/tests/Test-10.14.6.photoslibrary/database/RKVersion_searchIndexText.skindex and b/tests/Test-10.14.6.photoslibrary/database/RKVersion_searchIndexText.skindex differ
diff --git a/tests/Test-10.14.6.photoslibrary/database/photos.db b/tests/Test-10.14.6.photoslibrary/database/photos.db
index 4f1e44fd..ede28c3e 100644
Binary files a/tests/Test-10.14.6.photoslibrary/database/photos.db and b/tests/Test-10.14.6.photoslibrary/database/photos.db differ
diff --git a/tests/Test-10.14.6.photoslibrary/private/com.apple.photoanalysisd/GraphService/PhotoAnalysisServicePreferences.plist b/tests/Test-10.14.6.photoslibrary/private/com.apple.photoanalysisd/GraphService/PhotoAnalysisServicePreferences.plist
index 1e99f93e..02189263 100644
--- a/tests/Test-10.14.6.photoslibrary/private/com.apple.photoanalysisd/GraphService/PhotoAnalysisServicePreferences.plist
+++ b/tests/Test-10.14.6.photoslibrary/private/com.apple.photoanalysisd/GraphService/PhotoAnalysisServicePreferences.plist
@@ -3,8 +3,8 @@
PhotoAnalysisGraphLastBackgroundGraphRebuildJobDate
- 2020-10-04T23:43:21Z
+ 2020-10-09T16:14:42Z
PhotoAnalysisGraphLastBackgroundMemoryGenerationJobDate
- 2020-10-05T04:14:45Z
+ 2020-10-09T19:48:34Z
diff --git a/tests/Test-10.14.6.photoslibrary/private/com.apple.photoanalysisd/GraphService/PhotosGraph/photosgraph.graphdb b/tests/Test-10.14.6.photoslibrary/private/com.apple.photoanalysisd/GraphService/PhotosGraph/photosgraph.graphdb
index 8f55e1aa..8b42ee7a 100644
Binary files a/tests/Test-10.14.6.photoslibrary/private/com.apple.photoanalysisd/GraphService/PhotosGraph/photosgraph.graphdb and b/tests/Test-10.14.6.photoslibrary/private/com.apple.photoanalysisd/GraphService/PhotosGraph/photosgraph.graphdb differ
diff --git a/tests/Test-10.14.6.photoslibrary/private/com.apple.photoanalysisd/GraphService/PhotosGraph/photosgraph.graphdb-shm b/tests/Test-10.14.6.photoslibrary/private/com.apple.photoanalysisd/GraphService/PhotosGraph/photosgraph.graphdb-shm
index fe9ac284..87d3e641 100644
Binary files a/tests/Test-10.14.6.photoslibrary/private/com.apple.photoanalysisd/GraphService/PhotosGraph/photosgraph.graphdb-shm and b/tests/Test-10.14.6.photoslibrary/private/com.apple.photoanalysisd/GraphService/PhotosGraph/photosgraph.graphdb-shm differ
diff --git a/tests/Test-10.14.6.photoslibrary/resources/moments/historicalmarker.plist b/tests/Test-10.14.6.photoslibrary/resources/moments/historicalmarker.plist
index cdcb374c..7505f349 100644
--- a/tests/Test-10.14.6.photoslibrary/resources/moments/historicalmarker.plist
+++ b/tests/Test-10.14.6.photoslibrary/resources/moments/historicalmarker.plist
@@ -3,7 +3,7 @@
LastHistoryRowId
- 947
+ 948
LibraryBuildTag
D8C4AAA1-3AB6-4A65-BEBD-99CC3E5D433E
LibrarySchemaVersion
diff --git a/tests/Test-10.14.6.photoslibrary/resources/recovery/Info.plist b/tests/Test-10.14.6.photoslibrary/resources/recovery/Info.plist
index e71916e9..1d2de6d3 100644
--- a/tests/Test-10.14.6.photoslibrary/resources/recovery/Info.plist
+++ b/tests/Test-10.14.6.photoslibrary/resources/recovery/Info.plist
@@ -9,7 +9,7 @@
HistoricalMarker
LastHistoryRowId
- 947
+ 948
LibraryBuildTag
D8C4AAA1-3AB6-4A65-BEBD-99CC3E5D433E
LibrarySchemaVersion
@@ -24,7 +24,7 @@
SnapshotCompletedDate
2019-07-27T13:16:43Z
SnapshotLastValidated
- 2020-10-04T23:49:39Z
+ 2020-10-09T16:16:27Z
SnapshotTables
diff --git a/tests/Test-10.14.6.photoslibrary/resources/recovery/RKVersion/0000000000.lij b/tests/Test-10.14.6.photoslibrary/resources/recovery/RKVersion/0000000000.lij
index 53ec356a..fc3febb5 100644
Binary files a/tests/Test-10.14.6.photoslibrary/resources/recovery/RKVersion/0000000000.lij and b/tests/Test-10.14.6.photoslibrary/resources/recovery/RKVersion/0000000000.lij differ
diff --git a/tests/test_mojave_10_14_6.py b/tests/test_mojave_10_14_6.py
index cef5d73d..2fe39af7 100644
--- a/tests/test_mojave_10_14_6.py
+++ b/tests/test_mojave_10_14_6.py
@@ -76,7 +76,7 @@ UUID_UTI_DICT = {
None,
],
"oTiMG6OfSP6d%nUTEOfvMg": [
- "com.canon.cr2-raw-image",
+ "public.jpeg",
"com.canon.cr2-raw-image",
"com.canon.cr2-raw-image",
None,