Handle corrupt captures
This commit is contained in:
parent
a7fc14d93f
commit
9ab1da34ff
1 changed files with 5 additions and 1 deletions
|
|
@ -10,6 +10,7 @@ from PIL import Image
|
||||||
import atexit
|
import atexit
|
||||||
|
|
||||||
from openflexure_microscope.camera import piexif
|
from openflexure_microscope.camera import piexif
|
||||||
|
from openflexure_microscope.camera.piexif._exceptions import InvalidImageDataError
|
||||||
|
|
||||||
"""
|
"""
|
||||||
Attributes:
|
Attributes:
|
||||||
|
|
@ -44,7 +45,10 @@ def pull_usercomment_dict(filepath):
|
||||||
Args:
|
Args:
|
||||||
filepath: Path to the Exif-containing file
|
filepath: Path to the Exif-containing file
|
||||||
"""
|
"""
|
||||||
exif_dict = piexif.load(filepath)
|
try:
|
||||||
|
exif_dict = piexif.load(filepath)
|
||||||
|
except InvalidImageDataError:
|
||||||
|
logging.error("Invalid data at {}. Skipping.".format(filepath))
|
||||||
if 'Exif' in exif_dict and 37510 in exif_dict['Exif']:
|
if 'Exif' in exif_dict and 37510 in exif_dict['Exif']:
|
||||||
return yaml.load(exif_dict['Exif'][37510].decode())
|
return yaml.load(exif_dict['Exif'][37510].decode())
|
||||||
else:
|
else:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue