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:
jevans 2014-11-17 21:07:36 -05:00
commit 3fa3072041
2 changed files with 5 additions and 7 deletions

View file

@ -937,10 +937,8 @@ class Jp2k(Jp2kBox):
elif opj.OPENJPEG is not None:
img = self._read_openjpeg(**kwargs)
else:
raise LibraryNotFoundError("You must have either a recent version "
"of OpenJPEG or the development "
"version of OpenJP2 installed before "
"using this functionality.")
raise LibraryNotFoundError("You must have OpenJPEG installed "
"before reading a JPEG2000 image.")
return img
def _subsampling_sanity_check(self):
@ -1235,8 +1233,8 @@ class Jp2k(Jp2kBox):
"""
if version.openjpeg_version_tuple[0] < 2:
raise LibraryNotFoundError("You must have at least version 2.0.0 "
"of OpenJP2 installed before using "
"this functionality.")
"of OpenJPEG installed before using "
"read_bands.")
dparam = self._populate_dparam(rlevel, ignore_pclr_cmap_cdef,
layer=layer, tile=tile, area=area)

View file

@ -146,7 +146,7 @@ def glymur_config():
libopenjpeg_handle = load_openjpeg(libs['openjpeg'])
if libopenjp2_handle is None and libopenjpeg_handle is None:
msg = "Neither the openjp2 nor the openjpeg library could be loaded. "
raise IOError(msg)
warnings.warn(msg, UserWarning)
return libopenjp2_handle, libopenjpeg_handle