Skip to content

Commit 67e4c86

Browse files
Danielebrahimebrahim
authored andcommitted
Use Image.getexif() instead of Image._getexif() to avoid CI error
Issue #304
1 parent 59df50d commit 67e4c86

File tree

1 file changed

+6
-9
lines changed

1 file changed

+6
-9
lines changed

src/openlifu/nav/photoscan.py

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
import requests
2121
import trimesh
2222
import vtk
23-
from PIL import ExifTags, Image
23+
from PIL import Image
2424
from vtk.util.numpy_support import numpy_to_vtk
2525

2626
from openlifu.util.annotations import OpenLIFUFieldData
@@ -665,16 +665,13 @@ def write_pair_file(image_paths: List[Path], camera_init_file: Path, output_path
665665

666666

667667
def _get_datetime_taken(image_path: Path) -> datetime.datetime | None:
668-
"""Get the data and time from image metadata."""
668+
"""Get the date and time from image metadata."""
669669
with Image.open(image_path) as img:
670-
exif_data = img._getexif()
671-
if not exif_data:
670+
value = img.getexif().get(306, None)
671+
if value is None:
672672
return None
673-
for tag, value in exif_data.items():
674-
tag_name = ExifTags.TAGS.get(tag)
675-
if tag_name == 'DateTimeOriginal':
676-
return datetime.datetime.strptime(value, '%Y:%m:%d %H:%M:%S')
677-
return None
673+
else:
674+
return datetime.datetime.strptime(value, '%Y:%m:%d %H:%M:%S')
678675

679676
def _extract_numbers(filename: str) -> List[int]:
680677
"""Extracts all sub-strings of numbers as a list of ints."""

0 commit comments

Comments
 (0)