diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 07efd8d..13a36b5 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -24,6 +24,7 @@ Fixed correctly depending on the selected images. * Removed black line under marching ants outline of crop mode, which would scale with the image and get potentially very thick. +* Fixed a crash when importing images with unsupported exif orientation info diff --git a/beeref/fileio/image.py b/beeref/fileio/image.py index d68db80..0a82a11 100644 --- a/beeref/fileio/image.py +++ b/beeref/fileio/image.py @@ -44,9 +44,13 @@ def exif_rotated_image(path=None): logger.exception(f'Exif parser failed on image: {path}') return img - if 'orientation' in exifimg.list_all(): - orientation = exifimg.orientation - else: + try: + if 'orientation' in exifimg.list_all(): + orientation = exifimg.orientation + else: + return img + except NotImplementedError: + logger.exception(f'Exif failed reading orientation of image: {path}') return img transform = QtGui.QTransform() diff --git a/tests/fileio/test_image.py b/tests/fileio/test_image.py index f309217..432a55f 100644 --- a/tests/fileio/test_image.py +++ b/tests/fileio/test_image.py @@ -29,6 +29,13 @@ def test_exif_rotated_image_exif_unpack_error(qapp, imgfilename3x3): assert img.isNull() is False +def test_exif_rotated_image_exif_notimplementederror(qapp, imgfilename3x3): + with patch('beeref.fileio.image.exif.Image.list_all', + side_effect=NotImplementedError()): + img = exif_rotated_image(imgfilename3x3) + assert img.isNull() is False + + @pytest.mark.parametrize('path,expected', [('test3x3.png', 'test3x3.png'), ('test3x3_orientation1.jpg', 'test3x3.jpg'),