Skip to content

Commit

Permalink
Merge pull request #675 from girder/handle-bad-jp2k
Browse files Browse the repository at this point in the history
Handle a change in the Glymur library.
  • Loading branch information
manthey authored Nov 8, 2021
2 parents 0a29523 + 7179458 commit c1e71f0
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Change Log

## Version 1.8.6

### Bug Fixes
- A change in the Glymur library affected how missing files were handled ([#675](../../pull/675))

## Version 1.8.5

### Improvements
Expand Down
7 changes: 5 additions & 2 deletions sources/gdal/large_image_source_gdal/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,11 @@
import numpy
import palettable
import PIL.Image
import pyproj
from osgeo import gdal, gdal_array, gdalconst, osr
from osgeo import gdal, gdal_array, gdalconst, osr # noqa I001
# pyproj stopped supporting older pythons, so its database is aging; as such,
# if on those older versions of python if it is imported before gdal, there can
# be a database version conflect; importing after gdal avoids this.
import pyproj # noqa I001
from pkg_resources import DistributionNotFound, get_distribution

import large_image
Expand Down
4 changes: 4 additions & 0 deletions sources/openjpeg/large_image_source_openjpeg/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,10 @@ def __init__(self, path, **kwargs):
self._pixelInfo = {}
try:
self._openjpeg = glymur.Jp2k(largeImagePath)
if not self._openjpeg.shape:
if not os.path.isfile(self._largeImagePath):
raise FileNotFoundError()
raise TileSourceError('File cannot be opened via Glymur and OpenJPEG.')
except (glymur.jp2box.InvalidJp2kError, struct.error):
raise TileSourceError('File cannot be opened via Glymur and OpenJPEG.')
except FileNotFoundError:
Expand Down

0 comments on commit c1e71f0

Please sign in to comment.