Compare commits
6 commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
982e70be79 | ||
|
|
d03870cc72 | ||
|
|
d45d74ff5d | ||
|
|
f1ce5520ff | ||
|
|
3fa3072041 | ||
|
|
29dfce7927 |
8 changed files with 47 additions and 11 deletions
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -13,6 +13,15 @@ import six
|
|||
|
||||
import glymur
|
||||
|
||||
# If openjpeg is not installed, many tests cannot be run.
|
||||
if glymur.version.openjpeg_version == "0.0.0":
|
||||
OPENJPEG_NOT_AVAILABLE = True
|
||||
OPENJPEG_NOT_AVAILABLE_MSG = "OpenJPEG library not installed"
|
||||
else:
|
||||
OPENJPEG_NOT_AVAILABLE = False
|
||||
OPENJPEG_NOT_AVAILABLE_MSG = None
|
||||
|
||||
|
||||
# Some versions of "six" on python3 cause problems when verifying warnings.
|
||||
# Only use when the version is 1.7 or higher.
|
||||
# And moreover, we only test using the 3.x infrastructure, never on 2.x.
|
||||
|
|
|
|||
|
|
@ -34,6 +34,7 @@ from glymur.jp2box import FileTypeBox, ImageHeaderBox, JP2HeaderBox
|
|||
from glymur.jp2box import JPEG2000SignatureBox
|
||||
from glymur.core import COLOR, OPACITY
|
||||
from glymur.core import RED, GREEN, BLUE, GREY, WHOLE_IMAGE
|
||||
from glymur.version import openjpeg_version
|
||||
|
||||
from .fixtures import (
|
||||
WARNING_INFRASTRUCTURE_ISSUE, WARNING_INFRASTRUCTURE_MSG,
|
||||
|
|
@ -54,6 +55,8 @@ def load_tests(loader, tests, ignore):
|
|||
tests.addTests(doctest.DocTestSuite('glymur.jp2box'))
|
||||
return tests
|
||||
|
||||
@unittest.skipIf(re.match('0|1.[0-2]', openjpeg_version) is not None,
|
||||
"Not supported with OpenJPEG {0}".format(openjpeg_version))
|
||||
@unittest.skipIf(os.name == "nt", "Temporary file issue on window.")
|
||||
class TestDataEntryURL(unittest.TestCase):
|
||||
"""Test suite for DataEntryURL boxes."""
|
||||
|
|
@ -119,7 +122,7 @@ class TestDataEntryURL(unittest.TestCase):
|
|||
self.assertEqual(url + chr(0), read_url)
|
||||
|
||||
|
||||
@unittest.skipIf(re.match(r'''(1|2.0.0)''',
|
||||
@unittest.skipIf(re.match(r'''0|1|2.0.0''',
|
||||
glymur.version.openjpeg_version) is not None,
|
||||
"Not supported until 2.1")
|
||||
@unittest.skipIf(os.name == "nt", "Temporary file issue on window.")
|
||||
|
|
|
|||
|
|
@ -54,6 +54,8 @@ def load_tests(loader, tests, ignore):
|
|||
return tests
|
||||
|
||||
|
||||
@unittest.skipIf(fixtures.OPENJPEG_NOT_AVAILABLE,
|
||||
fixtures.OPENJPEG_NOT_AVAILABLE_MSG)
|
||||
class SliceProtocolBase(unittest.TestCase):
|
||||
"""
|
||||
Test slice protocol, i.e. when using [ ] to read image data.
|
||||
|
|
@ -309,6 +311,8 @@ class TestSliceProtocolRead(SliceProtocolBase):
|
|||
expected = self.j2k.read(area=(5, 27, 533, 423), rlevel=5)
|
||||
np.testing.assert_array_equal(actual, expected)
|
||||
|
||||
@unittest.skipIf(fixtures.OPENJPEG_NOT_AVAILABLE,
|
||||
fixtures.OPENJPEG_NOT_AVAILABLE_MSG)
|
||||
@unittest.skipIf(OPJ_DATA_ROOT is None,
|
||||
"OPJ_DATA_ROOT environment variable not set")
|
||||
class TestSliceProtocolOpjData(unittest.TestCase):
|
||||
|
|
@ -460,6 +464,8 @@ class TestSliceProtocolOpjData(unittest.TestCase):
|
|||
expected = self.j2k_quarter_data[5:13, 38:50]
|
||||
np.testing.assert_array_equal(actual, expected)
|
||||
|
||||
@unittest.skipIf(fixtures.OPENJPEG_NOT_AVAILABLE,
|
||||
fixtures.OPENJPEG_NOT_AVAILABLE_MSG)
|
||||
class TestJp2k(unittest.TestCase):
|
||||
"""These tests should be run by just about all configuration."""
|
||||
|
||||
|
|
@ -488,7 +494,7 @@ class TestJp2k(unittest.TestCase):
|
|||
actdata = j2.read()
|
||||
self.assertTrue(fixtures.mse(actdata[0], expdata[0]) < 0.38)
|
||||
|
||||
@unittest.skipIf(re.match('1.[0-4]', openjpeg_version) is not None,
|
||||
@unittest.skipIf(re.match('0|1.[0-4]', openjpeg_version) is not None,
|
||||
"Not supported with OpenJPEG {0}".format(openjpeg_version))
|
||||
@unittest.skipIf(re.match('1.5.(1|2)', openjpeg_version) is not None,
|
||||
"Mysteriously fails in 1.5.1 and 1.5.2")
|
||||
|
|
@ -820,7 +826,7 @@ class TestJp2k(unittest.TestCase):
|
|||
self.assertEqual(data.shape, (1024, 1024, 3))
|
||||
|
||||
|
||||
@unittest.skipIf(re.match('1.[0-4]', openjpeg_version) is not None,
|
||||
@unittest.skipIf(re.match('0|1.[0-4]', openjpeg_version) is not None,
|
||||
"Not supported with OpenJPEG {0}".format(openjpeg_version))
|
||||
@unittest.skipIf(os.name == "nt", "NamedTemporaryFile issue on windows")
|
||||
class TestJp2k_write(unittest.TestCase):
|
||||
|
|
@ -966,6 +972,8 @@ class TestJp2k_write(unittest.TestCase):
|
|||
self.assertEqual(codestream.segment[2].spcod[0], glymur.core.CPRL)
|
||||
|
||||
|
||||
@unittest.skipIf(fixtures.OPENJPEG_NOT_AVAILABLE,
|
||||
fixtures.OPENJPEG_NOT_AVAILABLE_MSG)
|
||||
@unittest.skipIf(glymur.version.openjpeg_version_tuple[0] >= 2,
|
||||
"Negative tests only for version 1.x")
|
||||
class TestJp2k_1_x(unittest.TestCase):
|
||||
|
|
@ -1092,7 +1100,7 @@ class TestJp2k_2_0(unittest.TestCase):
|
|||
self.assertEqual(jasoc.box[3].box[1].box_id, 'xml ')
|
||||
|
||||
|
||||
@unittest.skipIf(re.match(r'''(1|2.0.0)''',
|
||||
@unittest.skipIf(re.match(r'''0|1|2.0.0''',
|
||||
glymur.version.openjpeg_version) is not None,
|
||||
"Not to be run until unless 2.0.1 or higher is present")
|
||||
class TestJp2k_2_1(unittest.TestCase):
|
||||
|
|
@ -1290,6 +1298,8 @@ class TestJp2kOpjDataRoot(unittest.TestCase):
|
|||
rgb_from_idx[r, c] = palette[idx[r, c]]
|
||||
np.testing.assert_array_equal(rgb, rgb_from_idx)
|
||||
|
||||
@unittest.skipIf(fixtures.OPENJPEG_NOT_AVAILABLE,
|
||||
fixtures.OPENJPEG_NOT_AVAILABLE_MSG)
|
||||
def test_read_differing_subsamples(self):
|
||||
"""should error out with read used on differently subsampled images"""
|
||||
# Verify that we error out appropriately if we use the read method
|
||||
|
|
|
|||
|
|
@ -37,6 +37,7 @@ import glymur
|
|||
from glymur import Jp2k
|
||||
from glymur.jp2box import FileTypeBox, ImageHeaderBox, ColourSpecificationBox
|
||||
|
||||
from . import fixtures
|
||||
from .fixtures import (
|
||||
OPJ_DATA_ROOT, MetadataBase,
|
||||
WARNING_INFRASTRUCTURE_ISSUE, WARNING_INFRASTRUCTURE_MSG,
|
||||
|
|
@ -44,6 +45,8 @@ from .fixtures import (
|
|||
)
|
||||
|
||||
|
||||
@unittest.skipIf(fixtures.OPENJPEG_NOT_AVAILABLE,
|
||||
fixtures.OPENJPEG_NOT_AVAILABLE_MSG)
|
||||
@unittest.skipIf(OPJ_DATA_ROOT is None,
|
||||
"OPJ_DATA_ROOT environment variable not set")
|
||||
class TestSuite(unittest.TestCase):
|
||||
|
|
@ -479,6 +482,8 @@ class TestSuiteWarns(MetadataBase):
|
|||
self.assertTrue(True)
|
||||
|
||||
|
||||
@unittest.skipIf(fixtures.OPENJPEG_NOT_AVAILABLE,
|
||||
fixtures.OPENJPEG_NOT_AVAILABLE_MSG)
|
||||
@unittest.skipIf(OPJ_DATA_ROOT is None,
|
||||
"OPJ_DATA_ROOT environment variable not set")
|
||||
@unittest.skipIf(glymur.version.openjpeg_version_tuple[0] == 1,
|
||||
|
|
@ -574,6 +579,8 @@ class TestSuiteBands(unittest.TestCase):
|
|||
self.assertTrue(True)
|
||||
|
||||
|
||||
@unittest.skipIf(fixtures.OPENJPEG_NOT_AVAILABLE,
|
||||
fixtures.OPENJPEG_NOT_AVAILABLE_MSG)
|
||||
@unittest.skipIf(OPJ_DATA_ROOT is None,
|
||||
"OPJ_DATA_ROOT environment variable not set")
|
||||
@unittest.skipIf(glymur.version.openjpeg_version_tuple[0] == 1,
|
||||
|
|
|
|||
|
|
@ -36,11 +36,14 @@ import numpy as np
|
|||
from glymur import Jp2k
|
||||
import glymur
|
||||
|
||||
from . import fixtures
|
||||
from .fixtures import OPJ_DATA_ROOT
|
||||
from .fixtures import WARNING_INFRASTRUCTURE_ISSUE, WARNING_INFRASTRUCTURE_MSG
|
||||
from .fixtures import mse, peak_tolerance, read_pgx, opj_data_file
|
||||
|
||||
|
||||
@unittest.skipIf(fixtures.OPENJPEG_NOT_AVAILABLE,
|
||||
fixtures.OPENJPEG_NOT_AVAILABLE_MSG)
|
||||
@unittest.skipIf(OPJ_DATA_ROOT is None,
|
||||
"OPJ_DATA_ROOT environment variable not set")
|
||||
@unittest.skipIf(re.match(r'''(1|2.0.0)''',
|
||||
|
|
@ -163,6 +166,8 @@ class TestSuite2point1(unittest.TestCase):
|
|||
with self.assertRaises(IOError):
|
||||
j.read()
|
||||
|
||||
@unittest.skipIf(fixtures.OPENJPEG_NOT_AVAILABLE,
|
||||
fixtures.OPENJPEG_NOT_AVAILABLE_MSG)
|
||||
@unittest.skipIf(OPJ_DATA_ROOT is None,
|
||||
"OPJ_DATA_ROOT environment variable not set")
|
||||
@unittest.skipIf(re.match(r'''(1|2.0.0)''',
|
||||
|
|
|
|||
|
|
@ -31,6 +31,8 @@ import lxml.etree as ET
|
|||
|
||||
import glymur
|
||||
from glymur import Jp2k, command_line
|
||||
from glymur.version import openjpeg_version
|
||||
|
||||
from . import fixtures
|
||||
from .fixtures import OPJ_DATA_ROOT, opj_data_file
|
||||
from .fixtures import WARNING_INFRASTRUCTURE_ISSUE, WARNING_INFRASTRUCTURE_MSG
|
||||
|
|
@ -106,6 +108,8 @@ class TestPrinting(unittest.TestCase):
|
|||
with self.assertRaises(TypeError):
|
||||
glymur.set_printoptions(hi='low')
|
||||
|
||||
@unittest.skipIf(re.match('0|1.[0-4]', openjpeg_version) is not None,
|
||||
"Not supported with OpenJPEG {0}".format(openjpeg_version))
|
||||
def test_asoc_label_box(self):
|
||||
"""verify printing of asoc, label boxes"""
|
||||
# Construct a fake file with an asoc and a label box, as
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue