From fe6c607e67e1b532619462576b89b8ed2d058680 Mon Sep 17 00:00:00 2001 From: John Evans Date: Sun, 15 Sep 2013 12:33:29 -0400 Subject: [PATCH 1/3] Openjpeg 1.3 reads this image as indices, not RGB. #116 --- glymur/test/test_opj_suite.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/glymur/test/test_opj_suite.py b/glymur/test/test_opj_suite.py index 36f0a7b..a5daf3e 100644 --- a/glymur/test/test_opj_suite.py +++ b/glymur/test/test_opj_suite.py @@ -645,7 +645,11 @@ class TestSuite(unittest.TestCase): jfile = opj_data_file('input/conformance/file9.jp2') jp2k = Jp2k(jfile) jpdata = jp2k.read() - self.assertEqual(jpdata.shape, (512, 768, 3)) + if re.match(r"""1\.3""", glymur.version.openjpeg_version): + # Version 1.3 reads the indexed image as indices, not as RGB. + self.assertEqual(jpdata.shape, (512, 768)) + else: + self.assertEqual(jpdata.shape, (512, 768, 3)) def test_NR_DEC_Bretagne2_j2k_1_decode(self): jfile = opj_data_file('input/nonregression/Bretagne2.j2k') From 7622b940739e4b1dd049603a5d7915ea27e41123 Mon Sep 17 00:00:00 2001 From: John Evans Date: Sun, 15 Sep 2013 12:34:00 -0400 Subject: [PATCH 2/3] Fixed typo in error message. #116 --- glymur/jp2k.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/glymur/jp2k.py b/glymur/jp2k.py index 03ffc71..00b71c2 100644 --- a/glymur/jp2k.py +++ b/glymur/jp2k.py @@ -949,7 +949,7 @@ class Jp2k(Jp2kBox): If glymur is unable to load the openjp2 library. """ 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 " "this functionality.") From bc1421bb19473845f6c7bf382aec51deb4388c18 Mon Sep 17 00:00:00 2001 From: John Evans Date: Mon, 16 Sep 2013 06:33:23 -0400 Subject: [PATCH 3/3] Qualified on 1.3, 1.4. Closes #116 --- glymur/test/test_conformance.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/glymur/test/test_conformance.py b/glymur/test/test_conformance.py index 3c7c9c4..5f53b5f 100644 --- a/glymur/test/test_conformance.py +++ b/glymur/test/test_conformance.py @@ -12,6 +12,7 @@ These tests deal with JPX/JP2/J2K images in the format-corpus repository. import os from os.path import join +import re import sys if sys.hexversion < 0x02070000: @@ -19,6 +20,7 @@ if sys.hexversion < 0x02070000: else: import unittest +import glymur from glymur import Jp2k try: @@ -39,6 +41,9 @@ except KeyError: class TestSuiteFormatCorpus(unittest.TestCase): """Test suite for files in format corpus repository.""" + @unittest.skipIf(re.match(r"""1\.[0123]""", + glymur.version.openjpeg_version) is not None, + "Needs 1.3+ to catch this.") def test_balloon_trunc1(self): """Has one byte shaved off of EOC marker.""" jfile = os.path.join(FORMAT_CORPUS_DATA_ROOT, @@ -54,6 +59,9 @@ class TestSuiteFormatCorpus(unittest.TestCase): with self.assertRaises(OSError): j2k.read(rlevel=-1) + @unittest.skipIf(re.match(r"""1\.[01234]""", + glymur.version.openjpeg_version) is not None, + "Needs 1.4+ to catch this.") def test_balloon_trunc2(self): """Shortened by 5000 bytes.""" jfile = os.path.join(FORMAT_CORPUS_DATA_ROOT,