From c2442192f6f1cf40d7a5ce17a7d0057cfceb7304 Mon Sep 17 00:00:00 2001 From: David Manthey Date: Fri, 18 Aug 2023 13:42:20 -0400 Subject: [PATCH] Harden when the bioformats reader claims it has a zero sized image --- CHANGELOG.md | 3 +++ sources/bioformats/large_image_source_bioformats/__init__.py | 4 +++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index dfe0abd8e..829811bf4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,9 @@ ## 1.23.4 +### Improvements +- Harden when the bioformats reader claims it has a zero sized image ([#1268](../../pull/1268)) + ### Changes - Adjust tifffile log level ([#1265](../../pull/1265)) - Use a newer version of the hammerjs touch events library in Girder ([#1266](../../pull/1266)) diff --git a/sources/bioformats/large_image_source_bioformats/__init__.py b/sources/bioformats/large_image_source_bioformats/__init__.py index c099b9f78..37ac3cc03 100644 --- a/sources/bioformats/large_image_source_bioformats/__init__.py +++ b/sources/bioformats/large_image_source_bioformats/__init__.py @@ -241,6 +241,9 @@ def __init__(self, path, **kwargs): # noqa self._metadata[key] = 1 self.sizeX = self._metadata['sizeX'] self.sizeY = self._metadata['sizeY'] + if self.sizeX <= 0 or self.sizeY <= 0: + msg = 'File cannot be opened with biofromats.' + raise TileSourceError(msg) self._computeTiles() self._computeLevels() self._computeMagnification() @@ -249,7 +252,6 @@ def __init__(self, path, **kwargs): # noqa self.logger.debug('File cannot be opened via Bioformats. (%s)', es) raise TileSourceError('File cannot be opened via Bioformats. (%s)' % es) except (AttributeError, UnicodeDecodeError): - raise self.logger.exception('The bioformats reader threw an unhandled exception.') msg = 'The bioformats reader threw an unhandled exception.' raise TileSourceError(msg)