Skip to content

Commit

Permalink
Merge pull request #1291 from girder/tiff-associated-image-logic
Browse files Browse the repository at this point in the history
Add more logic for determining associated images in tiff source
  • Loading branch information
manthey authored Sep 1, 2023
2 parents 6efc4a6 + a783324 commit 4c9c09f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

### Improvements
- Add [common] extra_requires ([#1288](../../pull/1288))
- Add more logic for determining associated images in tiff source ([#1291](../../pull/1291))

### Changes
- Internal metadata get endpoint is now public ([#1285](../../pull/1285))
Expand Down
7 changes: 5 additions & 2 deletions sources/tiff/large_image_source_tiff/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,7 @@ def _addAssociatedImage(self, largeImagePath, directoryNum, mustBeTiled=False, t
:param largeImagePath: path to the TIFF file.
:param directoryNum: libtiff directory number of the image.
:param mustBeTiles: if true, use tiled images. If false, require
:param mustBeTiled: if true, use tiled images. If false, require
untiled images.
:param topImage: if specified, add image-embedded metadata to this
image.
Expand All @@ -464,14 +464,17 @@ def _addAssociatedImage(self, largeImagePath, directoryNum, mustBeTiled=False, t
id = 'dir%d' % directoryNum
if not len(self._associatedImages):
id = 'macro'
if not id and not mustBeTiled:
id = {1: 'label', 9: 'macro'}.get(associated._tiffInfo.get('subfiletype'))
if not isinstance(id, str):
id = id.decode()
# Only use this as an associated image if the parsed id is
# a reasonable length, alphanumeric characters, and the
# image isn't too large.
if (id.isalnum() and len(id) > 3 and len(id) <= 20 and
associated._pixelInfo['width'] <= self._maxAssociatedImageSize and
associated._pixelInfo['height'] <= self._maxAssociatedImageSize):
associated._pixelInfo['height'] <= self._maxAssociatedImageSize and
id not in self._associatedImages):
image = associated._tiffFile.read_image()
# Optrascan scanners store xml image descriptions in a "tiled
# image". Check if this is the case, and, if so, parse such
Expand Down

0 comments on commit 4c9c09f

Please sign in to comment.