MCPcopy Create free account
hub / github.com/apple/ml-sharp / extract_exif

Function extract_exif

src/sharp/utils/io.py:84–94  ·  view source on GitHub ↗

Return exif information as a dictionary.

(img_pil: Image.Image)

Source from the content-addressed store, hash-verified

82
83
84def extract_exif(img_pil: Image.Image) -> dict[str, Any]:
85 """Return exif information as a dictionary."""
86 # Get full exif description from get_ifd(0x8769):
87 # cf https://pillow.readthedocs.io/en/stable/releasenotes/8.2.0.html#image-getexif-exif-and-gps-ifd # noqa
88 img_exif = img_pil.getexif().get_ifd(0x8769)
89 exif_dict = {ExifTags.TAGS[k]: v for k, v in img_exif.items() if k in ExifTags.TAGS}
90
91 # https://pillow.readthedocs.io/en/stable/_modules/PIL/TiffTags.html# # noqa
92 tiff_tags = img_pil.getexif()
93 tiff_dict = {TiffTags.TAGS_V2[k].name: v for k, v in tiff_tags.items() if k in TiffTags.TAGS_V2}
94 return {**exif_dict, **tiff_dict}
95
96
97def convert_focallength(width: float, height: float, f_mm: float = 30) -> float:

Callers 1

load_rgbFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected