Fixed path_derivatives to always return jpeg if photo is a photo

This commit is contained in:
Rhet Turnbull
2021-07-02 18:59:01 -07:00
parent b1b099257f
commit b4dbad5e74
2 changed files with 29 additions and 14 deletions

View File

@@ -1,3 +1,3 @@
""" version info """
__version__ = "0.42.54"
__version__ = "0.42.55"

View File

@@ -852,8 +852,12 @@ class PhotoInfo:
@property
def path_derivatives(self):
"""Return any derivative (preview) images associated with the photo as a list of paths, sorted by file size (largest first)"""
try:
return self._path_derivatives
except AttributeError:
if self._db._db_version <= _PHOTOS_4_VERSION:
return self._path_derivatives_4()
self._path_derivatives = self._path_derivatives_4()
return self._path_derivatives
directory = self._uuid[0] # first char of uuid
derivative_path = (
@@ -865,7 +869,18 @@ class PhotoInfo:
files = derivative_path.glob(f"{self.uuid}*.*")
files = sorted(files, reverse=True, key=lambda f: f.stat().st_size)
# 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"]
derivatives = [
str(filename) for filename in files if filename.suffix != ".THM"
]
if (
self.isphoto
and len(derivatives) > 1
and derivatives[0].endswith(".mov")
):
derivatives[1], derivatives[0] = derivatives[0], derivatives[1]
self._path_derivatives = derivatives
return self._path_derivatives
def _path_derivatives_4(self):
"""Return paths to all derivative (preview) files for Photos <= 4"""