diff --git a/glymur/data/12-v6.4.jpx b/glymur/data/12-v6.4.jpx deleted file mode 100644 index a3e0c60..0000000 Binary files a/glymur/data/12-v6.4.jpx and /dev/null differ diff --git a/glymur/data/__init__.py b/glymur/data/__init__.py index 2bcd7f8..de1e62a 100644 --- a/glymur/data/__init__.py +++ b/glymur/data/__init__.py @@ -34,13 +34,13 @@ def goodstuff(): def jpxfile(): - """Shortcut for specifying path to 12-v6.4.jpx. + """Shortcut for specifying path to heliov.jpx. Returns ------- file : str Platform-independent path to 12-v6.4.jpx """ - filename = pkg_resources.resource_filename(__name__, "12-v6.4.jpx") + filename = pkg_resources.resource_filename(__name__, "heliov.jpx") return filename diff --git a/glymur/data/heliov.jpx b/glymur/data/heliov.jpx new file mode 100644 index 0000000..c7d5cdb Binary files /dev/null and b/glymur/data/heliov.jpx differ diff --git a/glymur/test/test_jp2box.py b/glymur/test/test_jp2box.py index 82a9ad6..d537316 100644 --- a/glymur/test/test_jp2box.py +++ b/glymur/test/test_jp2box.py @@ -678,8 +678,9 @@ class TestWrap(unittest.TestCase): def test_jpx_to_jp2(self): """basic test for rewrapping a jpx file""" jpx = Jp2k(self.jpxfile) - idx = [0, 1, 3, 6] - boxes = [jpx.box[idx] for idx in [0, 1, 3, 6]] + # Use only the signature, file type, header, and 1st codestream. + lst = [0, 1, 2, 5] + boxes = [jpx.box[idx] for idx in lst] with tempfile.NamedTemporaryFile(suffix=".jp2") as tfile: jp2 = jpx.wrap(tfile.name, boxes=boxes) diff --git a/glymur/test/test_jp2box_jpx.py b/glymur/test/test_jp2box_jpx.py index 1f29524..98eac45 100644 --- a/glymur/test/test_jp2box_jpx.py +++ b/glymur/test/test_jp2box_jpx.py @@ -451,6 +451,7 @@ class TestJPX(unittest.TestCase): with tempfile.TemporaryFile() as tfile: ftbl.write(tfile) + @unittest.skip("No such jpx file anymore.") def test_jpx_rreq_mask_length_3(self): """There are some JPX files with rreq mask length of 3.""" jpx = Jp2k(self.jpxfile) @@ -479,12 +480,6 @@ class TestJPX(unittest.TestCase): self.assertEqual(jpx.box[-1].box_id, b'grp ') self.assertEqual(jpx.box[-1].box[0].box_id, 'free') - def test_free_box(self): - """Verify that we can handle a free box.""" - j = Jp2k(self.jpxfile) - self.assertEqual(j.box[16].box[0].box_id, 'free') - self.assertEqual(type(j.box[16].box[0]), glymur.jp2box.FreeBox) - def test_data_reference_requires_dtbl(self): """The existance of a data reference box requires a ftbl box as well.""" flag = 0 @@ -557,17 +552,17 @@ class TestJPX(unittest.TestCase): self.assertEqual(jpx.box[-1].box[0].data_reference, (3,)) def test_nlst(self): - """Verify that we can handle a free box.""" + """Verify that we can handle a number list box.""" j = Jp2k(self.jpxfile) - self.assertEqual(j.box[16].box[1].box[0].box_id, 'nlst') - self.assertEqual(type(j.box[16].box[1].box[0]), - glymur.jp2box.NumberListBox) + nlst = j.box[12].box[0].box[0] + self.assertEqual(nlst.box_id, 'nlst') + self.assertEqual(type(nlst), glymur.jp2box.NumberListBox) # Two associations. - self.assertEqual(len(j.box[16].box[1].box[0].associations), 2) + self.assertEqual(len(nlst.associations), 2) # Codestream 0 - self.assertEqual(j.box[16].box[1].box[0].associations[0], 1 << 24) + self.assertEqual(nlst.associations[0], 1 << 24) # Compositing Layer 0 - self.assertEqual(j.box[16].box[1].box[0].associations[1], 2 << 24) + self.assertEqual(nlst.associations[1], 2 << 24) diff --git a/glymur/test/test_jp2k.py b/glymur/test/test_jp2k.py index 222cde8..6cd1ffd 100644 --- a/glymur/test/test_jp2k.py +++ b/glymur/test/test_jp2k.py @@ -63,6 +63,24 @@ class TestJp2k(unittest.TestCase): def tearDown(self): pass + def test_no_cxform_pclr_jpx(self): + """Indices for pclr jpxfile if no color transform""" + j = Jp2k(self.jpxfile) + rgb = j.read() + idx = j.read(ignore_pclr_cmap_cdef=True) + nr, nc = 1024, 1024 + self.assertEqual(rgb.shape, (nr, nc, 3)) + self.assertEqual(idx.shape, (nr, nc)) + + # Should be able to manually reconstruct the RGB image from the palette + # and indices. + palette = j.box[2].box[2].palette + rgb_from_idx = np.zeros(rgb.shape, dtype=np.uint8) + for r in np.arange(nr): + for c in np.arange(nc): + rgb_from_idx[r, c] = palette[idx[r, c]] + np.testing.assert_array_equal(rgb, rgb_from_idx) + def test_repr(self): """Verify that results of __repr__ are eval-able.""" j = Jp2k(self.j2kfile) @@ -92,23 +110,6 @@ class TestJp2k(unittest.TestCase): with self.assertRaises(IOError): Jp2k(filename) - def test_no_cxform_pclr_jpx(self): - """Indices for pclr jpxfile if no color transform""" - j = Jp2k(self.jpxfile) - rgb = j.read() - idx = j.read(ignore_pclr_cmap_cdef=True) - self.assertEqual(rgb.shape, (1024, 1024, 3)) - self.assertEqual(idx.shape, (1024, 1024)) - - # Should be able to manually reconstruct the RGB image from the palette - # and indices. - palette = j.box[3].box[2].palette - rgb_from_idx = np.zeros(rgb.shape, dtype=np.uint8) - for r in np.arange(1024): - for c in np.arange(1024): - rgb_from_idx[r, c] = palette[idx[r, c]] - np.testing.assert_array_equal(rgb, rgb_from_idx) - def test_file_not_present(self): """Should error out if reading from a file that does not exist""" # Verify that we error out appropriately if not given an existing file diff --git a/glymur/test/test_printing.py b/glymur/test/test_printing.py index 5cd8347..d770916 100644 --- a/glymur/test/test_printing.py +++ b/glymur/test/test_printing.py @@ -78,8 +78,8 @@ class TestPrinting(unittest.TestCase): with patch('sys.stdout', new=StringIO()) as fake_out: print(jpx.box[-1]) actual = fake_out.getvalue().strip() - lines = ["Unknown Box (b'grp ') @ (695609, 20)", - ' Free Box (free) @ (695617, 12)'] + lines = ["Unknown Box (b'grp ') @ (1399071, 20)", + ' Free Box (free) @ (1399079, 12)'] expected = '\n'.join(lines) self.assertEqual(actual, expected)