From 618ab9c692e866cb2b0630e1113646b90a1fba69 Mon Sep 17 00:00:00 2001 From: jevans Date: Wed, 5 Jun 2013 22:37:29 -0400 Subject: [PATCH 1/4] Redoing fix that was somehow backed out? Closes #18. --- glymur/test/test_printing.py | 1 + 1 file changed, 1 insertion(+) diff --git a/glymur/test/test_printing.py b/glymur/test/test_printing.py index 8b7ba34..7680377 100644 --- a/glymur/test/test_printing.py +++ b/glymur/test/test_printing.py @@ -689,6 +689,7 @@ class TestPrinting(unittest.TestCase): # Now append the codestream. tfile2.write(codestream) + tfile2.flush() jasoc = glymur.Jp2k(tfile2.name) print(jasoc.box[3]) From c979d22eebc5a91c5f4d89fea4dde5534ac7ec85 Mon Sep 17 00:00:00 2001 From: John Evans Date: Thu, 6 Jun 2013 08:33:31 -0400 Subject: [PATCH 2/4] Fixed #28 --- glymur/jp2box.py | 10 +++--- glymur/test/test_jp2k.py | 14 ++++----- glymur/test/test_opj_suite.py | 48 ++++++++++++++--------------- glymur/test/test_opj_suite_write.py | 2 +- 4 files changed, 37 insertions(+), 37 deletions(-) diff --git a/glymur/jp2box.py b/glymur/jp2box.py index b8361d3..613d6f2 100644 --- a/glymur/jp2box.py +++ b/glymur/jp2box.py @@ -150,7 +150,7 @@ class ColourSpecificationBox(Jp2kBox): boxes. approximation : int Measure of colorspace accuracy. - color_space : int or None + colorspace : int or None Enumerated colorspace, corresponds to one of 'sRGB', 'greyscale', or 'YCC'. If not None, then icc_profile must be None. icc_profile : byte array or None @@ -170,8 +170,8 @@ class ColourSpecificationBox(Jp2kBox): if self.approximation is not 0: x = _approximation_display[self.approximation] msg += '\n Approximation: {0}'.format(x) - if self.color_space is not None: - x = _colorspace_map_display[self.color_space] + if self.colorspace is not None: + x = _colorspace_map_display[self.colorspace] msg += '\n Colorspace: {0}'.format(x) else: x = len(self.icc_profile) @@ -214,12 +214,12 @@ class ColourSpecificationBox(Jp2kBox): if method == 1: # enumerated colour space buffer = f.read(4) - kwargs['color_space'], = struct.unpack('>I', buffer) + kwargs['colorspace'], = struct.unpack('>I', buffer) kwargs['icc_profile'] = None else: # ICC profile - kwargs['color_space'] = None + kwargs['colorspace'] = None n = offset + length - f.tell() kwargs['icc_profile'] = f.read(n) diff --git a/glymur/test/test_jp2k.py b/glymur/test/test_jp2k.py index f84bd40..a32cda8 100644 --- a/glymur/test/test_jp2k.py +++ b/glymur/test/test_jp2k.py @@ -220,7 +220,7 @@ class TestJp2k(unittest.TestCase): self.assertEqual(jp2k.box[2].box[1].longname, 'Colour Specification') self.assertEqual(jp2k.box[2].box[1].precedence, 0) self.assertEqual(jp2k.box[2].box[1].approximation, 0) - self.assertEqual(jp2k.box[2].box[1].color_space, glymur.core.SRGB) + self.assertEqual(jp2k.box[2].box[1].colorspace, glymur.core.SRGB) self.assertIsNone(jp2k.box[2].box[1].icc_profile) @unittest.skipIf(data_root is None, @@ -370,14 +370,14 @@ class TestJp2k(unittest.TestCase): j = Jp2k(tfile.name, 'wb') data = np.zeros((128, 128, 3), dtype=np.uint8) j.write(data, colorspace='rgb') - self.assertEqual(j.box[2].box[1].color_space, glymur.core.SRGB) + self.assertEqual(j.box[2].box[1].colorspace, glymur.core.SRGB) def test_specify_gray(self): with tempfile.NamedTemporaryFile(suffix='.jp2') as tfile: j = Jp2k(tfile.name, 'wb') data = np.zeros((128, 128), dtype=np.uint8) j.write(data, colorspace='gray') - self.assertEqual(j.box[2].box[1].color_space, + self.assertEqual(j.box[2].box[1].colorspace, glymur.core.GREYSCALE) def test_specify_grey(self): @@ -385,7 +385,7 @@ class TestJp2k(unittest.TestCase): j = Jp2k(tfile.name, 'wb') data = np.zeros((128, 128), dtype=np.uint8) j.write(data, colorspace='grey') - self.assertEqual(j.box[2].box[1].color_space, + self.assertEqual(j.box[2].box[1].colorspace, glymur.core.GREYSCALE) def test_grey_with_extra_component(self): @@ -396,7 +396,7 @@ class TestJp2k(unittest.TestCase): self.assertEqual(j.box[2].box[0].height, 128) self.assertEqual(j.box[2].box[0].width, 128) self.assertEqual(j.box[2].box[0].num_components, 2) - self.assertEqual(j.box[2].box[1].color_space, + self.assertEqual(j.box[2].box[1].colorspace, glymur.core.GREYSCALE) def test_grey_with_two_extra_components(self): @@ -407,7 +407,7 @@ class TestJp2k(unittest.TestCase): self.assertEqual(j.box[2].box[0].height, 128) self.assertEqual(j.box[2].box[0].width, 128) self.assertEqual(j.box[2].box[0].num_components, 3) - self.assertEqual(j.box[2].box[1].color_space, + self.assertEqual(j.box[2].box[1].colorspace, glymur.core.GREYSCALE) def test_rgb_with_extra_component(self): @@ -418,7 +418,7 @@ class TestJp2k(unittest.TestCase): self.assertEqual(j.box[2].box[0].height, 128) self.assertEqual(j.box[2].box[0].width, 128) self.assertEqual(j.box[2].box[0].num_components, 4) - self.assertEqual(j.box[2].box[1].color_space, glymur.core.SRGB) + self.assertEqual(j.box[2].box[1].colorspace, glymur.core.SRGB) def test_specify_ycc(self): # We don't support writing YCC at the moment. diff --git a/glymur/test/test_opj_suite.py b/glymur/test/test_opj_suite.py index d9b5d11..15913e2 100644 --- a/glymur/test/test_opj_suite.py +++ b/glymur/test/test_opj_suite.py @@ -3403,7 +3403,7 @@ class TestSuite(unittest.TestCase): self.assertEqual(jp2.box[3].box[1].method, 1) self.assertEqual(jp2.box[3].box[1].precedence, 0) self.assertEqual(jp2.box[3].box[1].approximation, 1) # JPX exact ?? - self.assertEqual(jp2.box[3].box[1].color_space, glymur.core.SRGB) + self.assertEqual(jp2.box[3].box[1].colorspace, glymur.core.SRGB) # XML box tags = [x.tag for x in jp2.box[4].xml] @@ -3445,7 +3445,7 @@ class TestSuite(unittest.TestCase): self.assertEqual(jp2.box[2].box[1].method, 1) self.assertEqual(jp2.box[2].box[1].precedence, 0) self.assertEqual(jp2.box[2].box[1].approximation, 1) # JPX exact?? - self.assertEqual(jp2.box[2].box[1].color_space, glymur.core.YCC) + self.assertEqual(jp2.box[2].box[1].colorspace, glymur.core.YCC) # Jp2 Header # Channel Definition @@ -3491,7 +3491,7 @@ class TestSuite(unittest.TestCase): self.assertEqual(jp2.box[2].box[1].method, 1) self.assertEqual(jp2.box[2].box[1].precedence, 0) self.assertEqual(jp2.box[2].box[1].approximation, 1) # JPX exact - self.assertEqual(jp2.box[2].box[1].color_space, glymur.core.YCC) + self.assertEqual(jp2.box[2].box[1].colorspace, glymur.core.YCC) # sub-sampling codestream = jp2.get_codestream() @@ -3537,7 +3537,7 @@ class TestSuite(unittest.TestCase): self.assertEqual(jp2.box[2].box[1].method, 1) self.assertEqual(jp2.box[2].box[1].precedence, 0) self.assertEqual(jp2.box[2].box[1].approximation, 1) # JPX exact? - self.assertEqual(jp2.box[2].box[1].color_space, glymur.core.GREYSCALE) + self.assertEqual(jp2.box[2].box[1].colorspace, glymur.core.GREYSCALE) def test_NR_file5_dump(self): # Three 8-bit components in the ROMM-RGB colourspace, encapsulated in a @@ -3580,7 +3580,7 @@ class TestSuite(unittest.TestCase): self.assertEqual(jp2.box[3].box[1].precedence, 0) self.assertEqual(jp2.box[3].box[1].approximation, 1) # JPX exact self.assertEqual(len(jp2.box[3].box[1].icc_profile), 546) - self.assertIsNone(jp2.box[3].box[1].color_space) + self.assertIsNone(jp2.box[3].box[1].colorspace) # Jp2 Header # Colour specification @@ -3588,7 +3588,7 @@ class TestSuite(unittest.TestCase): self.assertEqual(jp2.box[3].box[2].precedence, 1) self.assertEqual(jp2.box[3].box[2].approximation, 1) # JPX exact self.assertIsNone(jp2.box[3].box[2].icc_profile) - self.assertEqual(jp2.box[3].box[2].color_space, + self.assertEqual(jp2.box[3].box[2].colorspace, glymur.core.ROMM_RGB) def test_NR_file6_dump(self): @@ -3626,7 +3626,7 @@ class TestSuite(unittest.TestCase): self.assertEqual(jp2.box[2].box[1].precedence, 0) self.assertEqual(jp2.box[2].box[1].approximation, 1) # JPX exact self.assertIsNone(jp2.box[2].box[1].icc_profile) - self.assertEqual(jp2.box[2].box[1].color_space, + self.assertEqual(jp2.box[2].box[1].colorspace, glymur.core.GREYSCALE) def test_NR_file7_dump(self): @@ -3675,7 +3675,7 @@ class TestSuite(unittest.TestCase): self.assertEqual(jp2.box[3].box[1].precedence, 0) self.assertEqual(jp2.box[3].box[1].approximation, 1) # JPX exact self.assertEqual(len(jp2.box[3].box[1].icc_profile), 13332) - self.assertIsNone(jp2.box[3].box[1].color_space) + self.assertIsNone(jp2.box[3].box[1].colorspace) # Jp2 Header # Colour specification @@ -3683,7 +3683,7 @@ class TestSuite(unittest.TestCase): self.assertEqual(jp2.box[3].box[2].precedence, 1) self.assertEqual(jp2.box[3].box[2].approximation, 1) # JPX exact self.assertIsNone(jp2.box[3].box[2].icc_profile) - self.assertEqual(jp2.box[3].box[2].color_space, + self.assertEqual(jp2.box[3].box[2].colorspace, glymur.core.E_SRGB) def test_NR_file8_dump(self): @@ -3724,7 +3724,7 @@ class TestSuite(unittest.TestCase): self.assertEqual(jp2.box[2].box[1].precedence, 0) self.assertEqual(jp2.box[2].box[1].approximation, 1) # JPX exact self.assertEqual(len(jp2.box[2].box[1].icc_profile), 414) - self.assertIsNone(jp2.box[2].box[1].color_space) + self.assertIsNone(jp2.box[2].box[1].colorspace) # XML box tags = [x.tag for x in jp2.box[3].xml] @@ -3796,7 +3796,7 @@ class TestSuite(unittest.TestCase): self.assertEqual(jp2.box[2].box[3].precedence, 0) self.assertEqual(jp2.box[2].box[3].approximation, 1) # JPX exact self.assertIsNone(jp2.box[2].box[3].icc_profile) - self.assertEqual(jp2.box[2].box[3].color_space, glymur.core.SRGB) + self.assertEqual(jp2.box[2].box[3].colorspace, glymur.core.SRGB) def test_NR_00042_j2k_dump(self): # Profile 3. @@ -5272,7 +5272,7 @@ class TestSuite(unittest.TestCase): self.assertEqual(jp2.box[2].box[1].method, 1) self.assertEqual(jp2.box[2].box[1].precedence, 0) self.assertEqual(jp2.box[2].box[1].approximation, 0) # not allowed? - self.assertEqual(jp2.box[2].box[1].color_space, glymur.core.SRGB) + self.assertEqual(jp2.box[2].box[1].colorspace, glymur.core.SRGB) c = jp2.box[3].main_header @@ -5405,7 +5405,7 @@ class TestSuite(unittest.TestCase): self.assertEqual(jp2.box[2].box[1].method, 1) self.assertEqual(jp2.box[2].box[1].precedence, 0) self.assertEqual(jp2.box[2].box[1].approximation, 0) # JP2 - self.assertEqual(jp2.box[2].box[1].color_space, glymur.core.SRGB) + self.assertEqual(jp2.box[2].box[1].colorspace, glymur.core.SRGB) c = jp2.box[3].main_header @@ -5533,7 +5533,7 @@ class TestSuite(unittest.TestCase): self.assertEqual(jp2.box[2].box[1].method, 1) self.assertEqual(jp2.box[2].box[1].precedence, 0) self.assertEqual(jp2.box[2].box[1].approximation, 0) # JP2 - self.assertEqual(jp2.box[2].box[1].color_space, glymur.core.YCC) + self.assertEqual(jp2.box[2].box[1].colorspace, glymur.core.YCC) c = jp2.box[3].main_header @@ -5673,7 +5673,7 @@ class TestSuite(unittest.TestCase): self.assertEqual(jp2.box[3].box[1].method, 1) # enumerated self.assertEqual(jp2.box[3].box[1].precedence, 2) self.assertEqual(jp2.box[3].box[1].approximation, 1) # exact - self.assertEqual(jp2.box[3].box[1].color_space, glymur.core.SRGB) + self.assertEqual(jp2.box[3].box[1].colorspace, glymur.core.SRGB) # Jp2 Header # Palette box. @@ -5784,7 +5784,7 @@ class TestSuite(unittest.TestCase): self.assertEqual(jp2.box[2].box[1].method, 1) self.assertEqual(jp2.box[2].box[1].precedence, 0) self.assertEqual(jp2.box[2].box[1].approximation, 0) - self.assertEqual(jp2.box[2].box[1].color_space, glymur.core.SRGB) + self.assertEqual(jp2.box[2].box[1].colorspace, glymur.core.SRGB) # Skip the 4th box, it is uknown. @@ -5884,7 +5884,7 @@ class TestSuite(unittest.TestCase): self.assertEqual(jp2.box[3].box[1].method, 1) # ICC self.assertEqual(jp2.box[3].box[1].precedence, 2) self.assertEqual(jp2.box[3].box[1].approximation, 1) # JPX exact - self.assertEqual(jp2.box[3].box[1].color_space, glymur.core.SRGB) + self.assertEqual(jp2.box[3].box[1].colorspace, glymur.core.SRGB) c = jp2.box[4].main_header @@ -5981,7 +5981,7 @@ class TestSuite(unittest.TestCase): self.assertEqual(jp2.box[2].box[1].method, 1) self.assertEqual(jp2.box[2].box[1].precedence, 0) self.assertEqual(jp2.box[2].box[1].approximation, 0) # JP2 - self.assertEqual(jp2.box[2].box[1].color_space, glymur.core.GREYSCALE) + self.assertEqual(jp2.box[2].box[1].colorspace, glymur.core.GREYSCALE) # Jp2 Header # Channel Definition @@ -6100,7 +6100,7 @@ class TestSuite(unittest.TestCase): self.assertEqual(jp2.box[3].box[1].method, 1) # enumerated self.assertEqual(jp2.box[3].box[1].precedence, 2) self.assertEqual(jp2.box[3].box[1].approximation, 1) # JPX exact - self.assertEqual(jp2.box[3].box[1].color_space, glymur.core.CMYK) + self.assertEqual(jp2.box[3].box[1].colorspace, glymur.core.CMYK) # Jp2 Header # Palette box. @@ -6214,7 +6214,7 @@ class TestSuite(unittest.TestCase): self.assertEqual(jp2.box[3].box[1].method, 1) # enumerated self.assertEqual(jp2.box[3].box[1].precedence, 2) self.assertEqual(jp2.box[3].box[1].approximation, 1) # JPX exact - self.assertEqual(jp2.box[3].box[1].color_space, glymur.core.SRGB) + self.assertEqual(jp2.box[3].box[1].colorspace, glymur.core.SRGB) # Jp2 Header # Palette box. @@ -6322,7 +6322,7 @@ class TestSuite(unittest.TestCase): self.assertEqual(jp2.box[2].box[1].method, 1) self.assertEqual(jp2.box[2].box[1].precedence, 0) self.assertEqual(jp2.box[2].box[1].approximation, 0) # JP2 - self.assertEqual(jp2.box[2].box[1].color_space, glymur.core.YCC) + self.assertEqual(jp2.box[2].box[1].colorspace, glymur.core.YCC) c = jp2.box[3].main_header @@ -6427,7 +6427,7 @@ class TestSuite(unittest.TestCase): self.assertEqual(jp2.box[2].box[1].precedence, 0) self.assertEqual(jp2.box[2].box[1].approximation, 0) # JP2 self.assertEqual(len(jp2.box[2].box[1].icc_profile), 1) - self.assertIsNone(jp2.box[2].box[1].color_space) + self.assertIsNone(jp2.box[2].box[1].colorspace) c = jp2.box[3].main_header @@ -6523,7 +6523,7 @@ class TestSuite(unittest.TestCase): self.assertEqual(jp2.box[2].box[1].precedence, 0) self.assertEqual(jp2.box[2].box[1].approximation, 0) # JP2 self.assertEqual(len(jp2.box[2].box[1].icc_profile), 1) - self.assertIsNone(jp2.box[2].box[1].color_space) + self.assertIsNone(jp2.box[2].box[1].colorspace) c = jp2.box[3].main_header @@ -6625,7 +6625,7 @@ class TestSuite(unittest.TestCase): self.assertEqual(jp2.box[3].box[1].precedence, 2) self.assertEqual(jp2.box[3].box[1].approximation, 1) # JPX exact self.assertEqual(len(jp2.box[3].box[1].icc_profile), 1328) - self.assertIsNone(jp2.box[3].box[1].color_space) + self.assertIsNone(jp2.box[3].box[1].colorspace) # UUID boxes. All mentioned in the RREQ box. self.assertEqual(jp2.box[2].vendor_feature[0], jp2.box[4].uuid) diff --git a/glymur/test/test_opj_suite_write.py b/glymur/test/test_opj_suite_write.py index 486521f..d511768 100644 --- a/glymur/test/test_opj_suite_write.py +++ b/glymur/test/test_opj_suite_write.py @@ -693,7 +693,7 @@ class TestSuiteWrite(unittest.TestCase): self.assertEqual(jp2.box[2].box[1].precedence, 0) self.assertEqual(jp2.box[2].box[1].approximation, 0) self.assertIsNone(jp2.box[2].box[1].icc_profile) - self.assertEqual(jp2.box[2].box[1].color_space, glymur.core.SRGB) + self.assertEqual(jp2.box[2].box[1].colorspace, glymur.core.SRGB) c = jp2.box[3].main_header From 7a193b2e3cc44dbec7aa1b6859c9a067c62d821f Mon Sep 17 00:00:00 2001 From: John Evans Date: Thu, 6 Jun 2013 08:42:56 -0400 Subject: [PATCH 3/4] Fixes #31, see http://docs.python.org/2/distutils/sourcedist.html#manifest --- MANIFEST | 22 ---------------------- MANIFEST.in | 4 ++++ 2 files changed, 4 insertions(+), 22 deletions(-) delete mode 100644 MANIFEST create mode 100644 MANIFEST.in diff --git a/MANIFEST b/MANIFEST deleted file mode 100644 index 281450e..0000000 --- a/MANIFEST +++ /dev/null @@ -1,22 +0,0 @@ -# file GENERATED by distutils, do NOT edit -setup.py -bin/jp2dump -glymur/__init__.py -glymur/codestream.py -glymur/core.py -glymur/jp2box.py -glymur/jp2dump.py -glymur/jp2k.py -glymur/data/nemo.jp2 -glymur/lib/__init__.py -glymur/lib/openjp2.py -glymur/lib/test/__init__.py -glymur/lib/test/test_openjp2.py -glymur/test/__init__.py -glymur/test/test_callbacks.py -glymur/test/test_codestream.py -glymur/test/test_jp2k.py -glymur/test/test_opj_suite.py -glymur/test/test_opj_suite_neg.py -glymur/test/test_opj_suite_write.py -glymur/test/test_printing.py diff --git a/MANIFEST.in b/MANIFEST.in new file mode 100644 index 0000000..160d333 --- /dev/null +++ b/MANIFEST.in @@ -0,0 +1,4 @@ +include *.txt *.md +recursive-include *.txt *.py +prune build +exclude readthedocs-pip-requirements.txt From 6550ee054f49e02e8866d3d933db63e3e26761f5 Mon Sep 17 00:00:00 2001 From: John Evans Date: Thu, 6 Jun 2013 08:46:58 -0400 Subject: [PATCH 4/4] Bumping to 0.1.5 --- CHANGES.txt | 3 +++ docs/source/conf.py | 2 +- setup.py | 2 +- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/CHANGES.txt b/CHANGES.txt index b8c6f05..b935fba 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -1,3 +1,6 @@ +Jun 06, 2013 - v0.1.5 Changed ColourSpecificationBox attribute "color_space" + to "colorspace". Fixed MANIFEST issue affecting PyPI installs. + Jun 05, 2013 - v0.1.4 Added Exif UUID read support. Jun 02, 2013 - v0.1.3p1 Raising IOErrors when code block size and precinct diff --git a/docs/source/conf.py b/docs/source/conf.py index 0d630c6..fe4de6d 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -78,7 +78,7 @@ copyright = u'2013, John Evans' # The short X.Y version. version = '0.1' # The full version, including alpha/beta/rc tags. -release = '0.1.4' +release = '0.1.5' # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. diff --git a/setup.py b/setup.py index 5febec4..962111b 100644 --- a/setup.py +++ b/setup.py @@ -1,7 +1,7 @@ from distutils.core import setup kwargs = {'name': 'Glymur', - 'version': '0.1.4', + 'version': '0.1.5', 'description': 'Tools for accessing JPEG2000 files', 'long_description': open('README.md').read(), 'author': 'John Evans',