diff --git a/glymur/jp2box.py b/glymur/jp2box.py index ba204a4..4307f48 100644 --- a/glymur/jp2box.py +++ b/glymur/jp2box.py @@ -1040,13 +1040,11 @@ class ContiguousCodestreamBox(Jp2kBox): msg = Jp2kBox.__str__(self) if _printoptions['short'] is True: return msg - if _printoptions['siz']: - msg += '\n' + self._indent(str(self.main_header.segment[1]), - indent_level=4) + if _printoptions['codestream'] is False: return msg for segment in self.main_header.segment: - msg += '\n' + self._indent(str(segment), indent_level=8) + msg += '\n' + self._indent(str(segment), indent_level=4) return msg @@ -1321,7 +1319,7 @@ class FileTypeBox(Jp2kBox): if sys.hexversion >= 0x03000000: try: entry = entry.decode('utf-8') - except UnicodeDecodeError as err: + except UnicodeDecodeError: # The entry is invalid, but we've got code to catch this # later on. pass @@ -3361,7 +3359,7 @@ def get_parseoptions(): """ return _parseoptions -_printoptions = {'short': False, 'xml': True, 'siz': True} +_printoptions = {'short': False, 'xml': True, 'codestream': True} def set_printoptions(**kwargs): diff --git a/glymur/test/fixtures.py b/glymur/test/fixtures.py index c7bab78..12b0c71 100644 --- a/glymur/test/fixtures.py +++ b/glymur/test/fixtures.py @@ -709,6 +709,190 @@ UUID Box (uuid) @ (77, 3146) UUID: be7acfcb-97a9-42e8-9c71-999491e3afac (XMP) Contiguous Codestream Box (jp2c) @ (3223, 1132296)""" +nemo = """JPEG 2000 Signature Box (jP ) @ (0, 12) + Signature: 0d0a870a +File Type Box (ftyp) @ (12, 20) + Brand: jp2 + Compatibility: ['jp2 '] +JP2 Header Box (jp2h) @ (32, 45) + Image Header Box (ihdr) @ (40, 22) + Size: [1456 2592 3] + Bitdepth: 8 + Signed: False + Compression: wavelet + Colorspace Unknown: False + Colour Specification Box (colr) @ (62, 15) + Method: enumerated colorspace + Precedence: 0 + Colorspace: sRGB +UUID Box (uuid) @ (77, 3146) + UUID: be7acfcb-97a9-42e8-9c71-999491e3afac (XMP) + UUID Data: + + + + + Google + 2013-02-09T14:47:53 + + + 1 + 72/1 + 72/1 + 2 + HTC + HTC Glacier + 2592 + 1456 + + + 8 + 8 + 8 + + + 2 + 3 + + + 1343036288/4294967295 + 1413044224/4294967295 + + + + + 2748779008/4294967295 + 1417339264/4294967295 + 1288490240/4294967295 + 2576980480/4294967295 + 644245120/4294967295 + 257698032/4294967295 + + + + + 1 + 2528 + 1424 + 353/100 + 0 + 0/1 + WGS-84 + 2013-02-09T14:47:53 + + + 76 + + + 0220 + 0100 + + + 1 + 2 + 3 + 0 + + + 42,20.56N + 71,5.29W + 2013-02-09T19:47:53Z + NETWORK + + + 2013-02-09T14:47:53 + + + + + Glymur + Python XMP Toolkit + + + + + + +Contiguous Codestream Box (jp2c) @ (3223, 1132296) + SOC marker segment @ (3231, 0) + SIZ marker segment @ (3233, 47) + Profile: no profile + Reference Grid Height, Width: (1456 x 2592) + Vertical, Horizontal Reference Grid Offset: (0 x 0) + Reference Tile Height, Width: (1456 x 2592) + Vertical, Horizontal Reference Tile Offset: (0 x 0) + Bitdepth: (8, 8, 8) + Signed: (False, False, False) + Vertical, Horizontal Subsampling: ((1, 1), (1, 1), (1, 1)) + COD marker segment @ (3282, 12) + Coding style: + Entropy coder, without partitions + SOP marker segments: False + EPH marker segments: False + Coding style parameters: + Progression order: LRCP + Number of layers: 2 + Multiple component transformation usage: reversible + Number of resolutions: 2 + Code block height, width: (64 x 64) + Wavelet transform: 5-3 reversible + Precinct size: default, 2^15 x 2^15 + Code block context: + Selective arithmetic coding bypass: False + Reset context probabilities on coding pass boundaries: False + Termination on each coding pass: False + Vertically stripe causal context: False + Predictable termination: False + Segmentation symbols: False + QCD marker segment @ (3296, 7) + Quantization style: no quantization, 2 guard bits + Step size: [(0, 8), (0, 9), (0, 9), (0, 10)] + CME marker segment @ (3305, 37) + "Created by OpenJPEG version 2.0.0" + SOT marker segment @ (3344, 10) + Tile part index: 0 + Tile part length: 1132173 + Tile part instance: 0 + Number of tile parts: 1 + COC marker segment @ (3356, 9) + Associated component: 1 + Coding style for this component: Entropy coder, PARTITION = 0 + Coding style parameters: + Number of resolutions: 2 + Code block height, width: (64 x 64) + Wavelet transform: 5-3 reversible + Code block context: + Selective arithmetic coding bypass: False + Reset context probabilities on coding pass boundaries: False + Termination on each coding pass: False + Vertically stripe causal context: False + Predictable termination: False + Segmentation symbols: False + QCC marker segment @ (3367, 8) + Associated Component: 1 + Quantization style: no quantization, 2 guard bits + Step size: [(0, 8), (0, 9), (0, 9), (0, 10)] + COC marker segment @ (3377, 9) + Associated component: 2 + Coding style for this component: Entropy coder, PARTITION = 0 + Coding style parameters: + Number of resolutions: 2 + Code block height, width: (64 x 64) + Wavelet transform: 5-3 reversible + Code block context: + Selective arithmetic coding bypass: False + Reset context probabilities on coding pass boundaries: False + Termination on each coding pass: False + Vertically stripe causal context: False + Predictable termination: False + Segmentation symbols: False + QCC marker segment @ (3388, 8) + Associated Component: 2 + Quantization style: no quantization, 2 guard bits + Step size: [(0, 8), (0, 9), (0, 9), (0, 10)] + SOD marker segment @ (3398, 0) + EOC marker segment @ (1135517, 0)""" + # Output of reader requirements printing for text_GBR.jp2 text_GBR_rreq = r"""Reader Requirements Box (rreq) @ (40, 109) Fully Understands Aspect Mask: 0xffff diff --git a/glymur/test/test_printing.py b/glymur/test/test_printing.py index 49fec57..55e3018 100644 --- a/glymur/test/test_printing.py +++ b/glymur/test/test_printing.py @@ -1098,7 +1098,12 @@ class TestJp2dump(unittest.TestCase): """Verify dumping with -x, suppress XML.""" actual = self.run_jp2dump(['', '-x', self.jp2file]) - self.assertEqual(actual, fixtures.nemo_dump_no_codestream_no_xml) + # shave off the XML and non-main-header segments + lines = fixtures.nemo.split('\n') + expected = lines[0:18] + expected.extend(lines[104:140]) + expected = '\n'.join(expected) + self.assertEqual(actual, expected) @unittest.skipIf(sys.hexversion < 0x03000000, "assertRegex not in 2.7") def test_codestream_0_with_j2k_file(self):