diff --git a/osxphotos/_version.py b/osxphotos/_version.py index 9fa5a3dc..51f85b43 100644 --- a/osxphotos/_version.py +++ b/osxphotos/_version.py @@ -1,3 +1,3 @@ """ version info """ -__version__ = "0.42.49" +__version__ = "0.42.50" diff --git a/osxphotos/photoinfo/photoinfo.py b/osxphotos/photoinfo/photoinfo.py index af16548e..fe0ca47e 100644 --- a/osxphotos/photoinfo/photoinfo.py +++ b/osxphotos/photoinfo/photoinfo.py @@ -390,19 +390,19 @@ class PhotoInfo: photopath = None else: filestem = pathlib.Path(self._info["filename"]).stem - raw_ext = get_preferred_uti_extension(self._info["UTI_raw"]) + # raw_ext = get_preferred_uti_extension(self._info["UTI_raw"]) if self._info["directory"].startswith("/"): filepath = self._info["directory"] else: filepath = os.path.join(self._db._masters_path, self._info["directory"]) - glob_str = f"{filestem}*.{raw_ext}" + # raw files have same name as original but with _4.raw_ext appended + # I believe the _4 maps to PHAssetResourceTypeAlternatePhoto = 4 + # see: https://developer.apple.com/documentation/photokit/phassetresourcetype/phassetresourcetypealternatephoto?language=objc + glob_str = f"{filestem}_4*" raw_file = findfiles(glob_str, filepath) - if len(raw_file) != 1: - # Note: In Photos Version 5.0 (141.19.150), images not copied to Photos Library - # that are missing do not always trigger is_missing = True as happens - # in earlier version so it's possible for this check to fail, if so, return None + if not raw_file: photopath = None else: photopath = os.path.join(filepath, raw_file[0]) @@ -693,7 +693,14 @@ class PhotoInfo: for example: com.canon.cr2-raw-image Returns None if no associated RAW image """ - return self._info["UTI_raw"] + if self._db._photos_ver < 7: + return self._info["UTI_raw"] + + rawpath = self.path_raw + if rawpath: + return get_uti_for_extension(pathlib.Path(rawpath).suffix) + else: + return None @property def ismovie(self): diff --git a/tests/test_monterey_dev_beta_12_0_0.py b/tests/test_monterey_dev_beta_12_0_0.py index d6ad2eb8..95bd8ae8 100644 --- a/tests/test_monterey_dev_beta_12_0_0.py +++ b/tests/test_monterey_dev_beta_12_0_0.py @@ -1188,7 +1188,6 @@ def test_uti(photosdb): assert photo.uti_original == UTI_ORIGINAL_DICT[uuid] -@pytest.mark.skip(reason="RAW+JPEG not yet working on Monterey") def test_raw(photosdb): """Test various raw properties"""