From a337e79e13802b4824c2f088ce9db1c027d6f3c5 Mon Sep 17 00:00:00 2001 From: Rhet Turnbull Date: Sun, 19 Apr 2020 19:16:43 -0700 Subject: [PATCH] added raw_is_original handling --- osxphotos/photoinfo.py | 9 +++++++-- osxphotos/photosdb.py | 7 ++++++- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/osxphotos/photoinfo.py b/osxphotos/photoinfo.py index 319e9e43..8e44ac1a 100644 --- a/osxphotos/photoinfo.py +++ b/osxphotos/photoinfo.py @@ -53,7 +53,12 @@ class PhotoInfo: @property def filename(self): """ filename of the picture """ - return self._info["filename"] + if self.has_raw and self.raw_original: + # return name of the RAW file + # TODO: not yet implemented + return self._info["filename"] + else: + return self._info["filename"] @property def original_filename(self): @@ -613,7 +618,7 @@ class PhotoInfo: """ returns True if associated RAW image and the RAW image is selected in Photos via "Use RAW as Original " otherwise returns False """ - return True if self._info["original_resource_choice"] == 1 else False + return self._info["raw_is_original"] def export( self, diff --git a/osxphotos/photosdb.py b/osxphotos/photosdb.py index 3c408521..9f251c93 100644 --- a/osxphotos/photosdb.py +++ b/osxphotos/photosdb.py @@ -528,7 +528,6 @@ class PhotosDB: """ process the Photos database to extract info works on Photos version <= 4.0 """ - # TODO: Update strings to remove + (not needed) # Epoch is Jan 1, 2001 td = (datetime(2001, 1, 1, 0, 0) - datetime(1970, 1, 1, 0, 0)).total_seconds() @@ -888,6 +887,7 @@ class PhotosDB: # 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 # associated RAW image info self._dbphotos[uuid]["has_raw"] = True if row[25] == 7 else False @@ -1607,7 +1607,12 @@ class PhotosDB: info["momentID"] = row[26] # original resource choice (e.g. RAW or jpeg) + # for images part of a RAW/jpeg pair, + # ZADDITIONALASSETATTRIBUTES.ZORIGINALRESOURCECHOICE + # = 0 if jpeg is selected as "original" in Photos (the default) + # = 1 if RAW is selected as "original" in Photos info["original_resource_choice"] = row[27] + info["raw_is_original"] = True if row[27] == 1 else False # associated RAW image info # will be filled in later