warn instead of raising IOError if openjpeg library cannot be found, issue#300
Improve error message when trying to read without openjpeg library.
This commit is contained in:
parent
76014f9402
commit
3fa3072041
2 changed files with 5 additions and 7 deletions
|
|
@ -937,10 +937,8 @@ class Jp2k(Jp2kBox):
|
||||||
elif opj.OPENJPEG is not None:
|
elif opj.OPENJPEG is not None:
|
||||||
img = self._read_openjpeg(**kwargs)
|
img = self._read_openjpeg(**kwargs)
|
||||||
else:
|
else:
|
||||||
raise LibraryNotFoundError("You must have either a recent version "
|
raise LibraryNotFoundError("You must have OpenJPEG installed "
|
||||||
"of OpenJPEG or the development "
|
"before reading a JPEG2000 image.")
|
||||||
"version of OpenJP2 installed before "
|
|
||||||
"using this functionality.")
|
|
||||||
return img
|
return img
|
||||||
|
|
||||||
def _subsampling_sanity_check(self):
|
def _subsampling_sanity_check(self):
|
||||||
|
|
@ -1235,8 +1233,8 @@ class Jp2k(Jp2kBox):
|
||||||
"""
|
"""
|
||||||
if version.openjpeg_version_tuple[0] < 2:
|
if version.openjpeg_version_tuple[0] < 2:
|
||||||
raise LibraryNotFoundError("You must have at least version 2.0.0 "
|
raise LibraryNotFoundError("You must have at least version 2.0.0 "
|
||||||
"of OpenJP2 installed before using "
|
"of OpenJPEG installed before using "
|
||||||
"this functionality.")
|
"read_bands.")
|
||||||
|
|
||||||
dparam = self._populate_dparam(rlevel, ignore_pclr_cmap_cdef,
|
dparam = self._populate_dparam(rlevel, ignore_pclr_cmap_cdef,
|
||||||
layer=layer, tile=tile, area=area)
|
layer=layer, tile=tile, area=area)
|
||||||
|
|
|
||||||
|
|
@ -146,7 +146,7 @@ def glymur_config():
|
||||||
libopenjpeg_handle = load_openjpeg(libs['openjpeg'])
|
libopenjpeg_handle = load_openjpeg(libs['openjpeg'])
|
||||||
if libopenjp2_handle is None and libopenjpeg_handle is None:
|
if libopenjp2_handle is None and libopenjpeg_handle is None:
|
||||||
msg = "Neither the openjp2 nor the openjpeg library could be loaded. "
|
msg = "Neither the openjp2 nor the openjpeg library could be loaded. "
|
||||||
raise IOError(msg)
|
warnings.warn(msg, UserWarning)
|
||||||
return libopenjp2_handle, libopenjpeg_handle
|
return libopenjp2_handle, libopenjpeg_handle
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue