From 6ac14e23829f51e98082d128937e2de033504877 Mon Sep 17 00:00:00 2001 From: David Manthey Date: Wed, 15 Nov 2023 23:19:19 -0500 Subject: [PATCH] Guard against bad tifffile magnification values --- CHANGELOG.md | 1 + sources/tifffile/large_image_source_tifffile/__init__.py | 6 ++++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1acd87e77..b03f7894f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -21,6 +21,7 @@ - Fix series detection for some bioformats files ([#1365](../../pull/1365), [#1367](../../pull/1367)) - Fix time comparison in annotation history check ([#1369](../../pull/1369)) - Fix an issue with apply a frame style to ome tiffs ([#1374](../../pull/1374)) +- Guard against bad tifffile magnification values ([#1376](../../pull/1376)) ## 1.26.0 diff --git a/sources/tifffile/large_image_source_tifffile/__init__.py b/sources/tifffile/large_image_source_tifffile/__init__.py index 2fbce1776..9aa70c18d 100644 --- a/sources/tifffile/large_image_source_tifffile/__init__.py +++ b/sources/tifffile/large_image_source_tifffile/__init__.py @@ -125,10 +125,12 @@ def __init__(self, path, **kwargs): # noqa try: unit = {2: 25.4, 3: 10}[page.tags['ResolutionUnit'].value.real] - if page.tags['XResolution'].value[1] >= 100: + if (page.tags['XResolution'].value[0] and ( + page.tags['XResolution'].value[1] / page.tags['XResolution'].value[0]) >= 100): self._mm_x = (unit * page.tags['XResolution'].value[1] / page.tags['XResolution'].value[0]) - if page.tags['YResolution'].value[1] >= 100: + if (page.tags['YResolution'].value[0] and ( + page.tags['YResolution'].value[1] / page.tags['YResolution'].value[0]) >= 100): self._mm_y = (unit * page.tags['YResolution'].value[1] / page.tags['YResolution'].value[0]) except Exception: