Skip to content

Commit

Permalink
Merge pull request #560 from girder/pil-source-priority
Browse files Browse the repository at this point in the history
Increase the priority level of the PIL tile source.
  • Loading branch information
manthey authored Mar 4, 2021
2 parents 44b15b9 + a141acc commit 683216b
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 683216b

Please sign in to comment.