Skip to content

Commit af0693e

Browse files
authored
don't open image on get_img_size (airctic#1084)
1 parent 0d4d689 commit af0693e

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

icevision/utils/imageio.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -89,10 +89,10 @@ def get_img_size(filepath: Union[str, Path]) -> ImgSize:
8989
"""
9090
if ".dcm" in str(filepath).lower():
9191
image = open_dicom(str(filepath))
92+
image_size = image.size
9293
else:
93-
image = PIL.Image.open(str(filepath))
94-
95-
image_size = image.size
94+
with PIL.Image.open(str(filepath)) as image:
95+
image_size = image.size
9696

9797
try:
9898
exif = image._getexif()

0 commit comments

Comments
 (0)