Added path_derivatives for Photos 5, issue #50

This commit is contained in:
Rhet Turnbull
2021-05-08 15:11:59 -07:00
parent b23cfa32bb
commit 63834ab8ab
14 changed files with 113 additions and 5 deletions

View File

@@ -1,3 +1,3 @@
""" version info """
__version__ = "0.42.17"
__version__ = "0.42.18"

View File

@@ -818,6 +818,24 @@ class PhotoInfo:
return photopath
@property
def path_derivatives(self):
""" Return any derivative (preview) images associated with the photo as a list of paths,
currently only implemented for Photos >= 5 """
if self._db._db_version <= _PHOTOS_4_VERSION:
return []
directory = self._uuid[0] # first char of uuid
derivative_path = (
pathlib.Path(self._db._library_path)
/ "resources"
/ "derivatives"
/ directory
)
files = derivative_path.glob(f"{self.uuid}*.*")
# return list of filename but skip .THM files (these are actually low-res thumbnails in JPEG format but with .THM extension)
return [str(filename) for filename in files if filename.suffix != ".THM"]
@property
def panorama(self):
""" Returns True if photo is a panorama, otherwise False """