Fix for #570
This commit is contained in:
@@ -725,8 +725,10 @@ class PhotoInfo:
|
|||||||
self._uti_original = self.uti
|
self._uti_original = self.uti
|
||||||
elif self._db._photos_ver >= 7:
|
elif self._db._photos_ver >= 7:
|
||||||
# Monterey+
|
# Monterey+
|
||||||
self._uti_original = get_uti_for_extension(
|
# there are some cases with UTI_original is None (photo imported with no extension) so fallback to UTI and hope it's right
|
||||||
pathlib.Path(self.original_filename).suffix
|
self._uti_original = (
|
||||||
|
get_uti_for_extension(pathlib.Path(self.original_filename).suffix)
|
||||||
|
or self.uti
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
self._uti_original = self._info["UTI_original"]
|
self._uti_original = self._info["UTI_original"]
|
||||||
@@ -1025,7 +1027,7 @@ class PhotoInfo:
|
|||||||
@property
|
@property
|
||||||
def israw(self):
|
def israw(self):
|
||||||
"""returns True if photo is a raw image. For images with an associated RAW+JPEG pair, see has_raw"""
|
"""returns True if photo is a raw image. For images with an associated RAW+JPEG pair, see has_raw"""
|
||||||
return "raw-image" in self.uti_original
|
return "raw-image" in self.uti_original if self.uti_original else False
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def raw_original(self):
|
def raw_original(self):
|
||||||
|
|||||||
@@ -520,7 +520,8 @@ class PhotoAsset:
|
|||||||
== Photos.PHAssetResourceTypeAlternatePhoto
|
== Photos.PHAssetResourceTypeAlternatePhoto
|
||||||
):
|
):
|
||||||
data = self._request_resource_data(resource)
|
data = self._request_resource_data(resource)
|
||||||
ext = pathlib.Path(self.raw_filename).suffix[1:]
|
suffix = pathlib.Path(self.raw_filename).suffix
|
||||||
|
ext = suffix[1:] if suffix else ""
|
||||||
break
|
break
|
||||||
else:
|
else:
|
||||||
raise PhotoKitExportError(
|
raise PhotoKitExportError(
|
||||||
|
|||||||
@@ -591,6 +591,9 @@ def get_preferred_uti_extension(uti):
|
|||||||
def get_uti_for_extension(extension):
|
def get_uti_for_extension(extension):
|
||||||
"""get UTI for a given file extension"""
|
"""get UTI for a given file extension"""
|
||||||
|
|
||||||
|
if not extension:
|
||||||
|
return None
|
||||||
|
|
||||||
# accepts extension with or without leading 0
|
# accepts extension with or without leading 0
|
||||||
if extension[0] == ".":
|
if extension[0] == ".":
|
||||||
extension = extension[1:]
|
extension = extension[1:]
|
||||||
|
|||||||
Reference in New Issue
Block a user