Skip to content

Commit

Permalink
Increase the priority level of the PIL tile source.
Browse files Browse the repository at this point in the history
The PIL tilesource was a fallback source, but sources with the same
priority level are used in an arbitrary order, and it was desired to
make it higher priority than the bioformats source for small tiff files.
This introduces more resolution into the fallback priority ordering.
  • Loading branch information
manthey committed Mar 4, 2021
1 parent 44b15b9 commit a141acc
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 6 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
- Reduce gdal warning about projection strings (#559)
- Don't report needless frame information for some single frame files (#558)

### Changes
- The PIL tilesource priority is slightly higher than other fallback sources (#560)

### Bug Fixes
- Fix compositing when using different frame numbers and partial tiles (#557)

Expand Down
5 changes: 3 additions & 2 deletions large_image/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,9 @@ class SourcePriority:
MEDIUM = 4
LOW = 5
LOWER = 6
FALLBACK = 7
MANUAL = 8 # Will never be selected automatically
FALLBACK_HIGH = 7
FALLBACK = 8
MANUAL = 9 # Will never be selected automatically


TILE_FORMAT_IMAGE = 'image'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ def __init__(self, path, **kwargs): # noqa
raise TileSourceException(
'File cannot be opened via bioformats because it has no '
'extension to specify the file type (%s).' % largeImagePath)
if ext.lower() in ('.jpg', '.jpeg', '.jpe', '.png', '.tif', '.tiff'):
if ext.lower() in ('.jpg', '.jpeg', '.jpe', '.png'):
raise TileSourceException('File will not be opened by bioformats reader')

if not _startJavabridge(self._logger):
Expand Down
13 changes: 10 additions & 3 deletions sources/pil/large_image_source_pil/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

from large_image import config
from large_image.cache_util import LruCacheMetaclass, methodcache, strhash
from large_image.constants import TILE_FORMAT_PIL
from large_image.constants import TILE_FORMAT_PIL, SourcePriority
from large_image.exceptions import TileSourceException
from large_image.tilesource import FileTileSource

Expand Down Expand Up @@ -65,8 +65,15 @@ class PILFileTileSource(FileTileSource, metaclass=LruCacheMetaclass):

cacheName = 'tilesource'
name = 'pilfile'
# No extensions or mime types are explicitly added for the PIL tile source,
# as it should always be a fallback source

# Although PIL is always a fallback source, prefer it to other fallback
# sources
extensions = {
None: SourcePriority.FALLBACK_HIGH
}
mimeTypes = {
None: SourcePriority.FALLBACK_HIGH
}

def __init__(self, path, maxSize=None, **kwargs):
"""
Expand Down

0 comments on commit a141acc

Please sign in to comment.