Skip to content

Commit

Permalink
Merge pull request #513 from girder/store-li-path
Browse files Browse the repository at this point in the history
Store the large image path to avoid rerequesting it.
  • Loading branch information
manthey authored Jan 15, 2021
2 parents a3fe96e + 3975b17 commit d5c2ac0
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
1 change: 1 addition & 0 deletions sources/ometiff/large_image_source_ometiff/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ def __init__(self, path, **kwargs):
super(TiffFileTileSource, self).__init__(path, **kwargs)

largeImagePath = self._getLargeImagePath()
self._largeImagePath = largeImagePath

try:
base = TiledTiffDirectory(largeImagePath, 0, mustBeTiled=None)
Expand Down
3 changes: 2 additions & 1 deletion sources/openslide/large_image_source_openslide/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ def __init__(self, path, **kwargs):
'svslevel': bestlevel,
'scale': scale
})
self._largeImagePath = largeImagePath

def _getTileSize(self):
"""
Expand Down Expand Up @@ -371,7 +372,7 @@ def _getAssociatedImage(self, imageKey):
return self._openslide.associated_images[imageKey]
except openslide.lowlevel.OpenSlideError:
return None
bytePath = self._getLargeImagePath()
bytePath = self._largeImagePath
if not isinstance(bytePath, six.binary_type):
bytePath = bytePath.encode('utf8')
_tiffFile = libtiff_ctypes.TIFF.open(bytePath)
Expand Down
5 changes: 3 additions & 2 deletions sources/tiff/large_image_source_tiff/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ def __init__(self, path, **kwargs):
super(TiffFileTileSource, self).__init__(path, **kwargs)

largeImagePath = self._getLargeImagePath()
self._largeImagePath = largeImagePath
try:
alldir = self._scanDirectories()
except (ValidationTiffException, TiffException) as exc:
Expand Down Expand Up @@ -134,7 +135,7 @@ def __init__(self, path, **kwargs):
self.sizeY = highest.imageHeight

def _scanDirectories(self):
largeImagePath = self._getLargeImagePath()
largeImagePath = self._largeImagePath
lastException = None
# Associated images are smallish TIFF images that have an image
# description and are not tiled. They have their own TIFF directory.
Expand Down Expand Up @@ -382,7 +383,7 @@ def _getDirFromCache(self, dirnum, subdir=None):
self._directoryCache = {}
try:
result = TiledTiffDirectory(
self._getLargeImagePath(), dirnum, mustBeTiled=None, subDirectoryNum=subdir)
self._largeImagePath, dirnum, mustBeTiled=None, subDirectoryNum=subdir)
except IOTiffException:
result = None
self._directoryCache[key] = result
Expand Down

0 comments on commit d5c2ac0

Please sign in to comment.