diff --git a/glymur/jp2box.py b/glymur/jp2box.py index 969ed2c..f1409ee 100644 --- a/glymur/jp2box.py +++ b/glymur/jp2box.py @@ -728,6 +728,11 @@ class CodestreamHeaderBox(Jp2kBox): msg = self._str_superbox() return msg + def write(self, fptr): + """Write a codestream header box to file. + """ + self._write_superbox(fptr) + @staticmethod def parse(fptr, offset, length): """Parse codestream header box. @@ -792,7 +797,7 @@ class ColourGroupBox(Jp2kBox): self._dispatch_validation_error(msg, writing=writing) def write(self, fptr): - """Write an association box to file. + """Write a colour group box to file. """ self._validate(writing=True) self._write_superbox(fptr) @@ -855,6 +860,11 @@ class CompositingLayerHeaderBox(Jp2kBox): msg = self._str_superbox() return msg + def write(self, fptr): + """Write a compositing layer header box to file. + """ + self._write_superbox(fptr) + @staticmethod def parse(fptr, offset, length): """Parse compositing layer header box. diff --git a/glymur/test/test_jp2box_jpx.py b/glymur/test/test_jp2box_jpx.py index 75b9792..1f29524 100644 --- a/glymur/test/test_jp2box_jpx.py +++ b/glymur/test/test_jp2box_jpx.py @@ -110,6 +110,26 @@ class TestJPXWrap(unittest.TestCase): with self.assertRaises(IOError): jp2.wrap(tfile.name, boxes=boxes) + def test_jpch_jplh(self): + """Write a codestream header, compositing layer header box.""" + jp2 = Jp2k(self.jp2file) + boxes = [jp2.box[idx] for idx in [0, 1, 2, 4]] + + # The ftyp box must be modified to jpx. + boxes[1].brand = 'jpx ' + boxes[1].compatibility_list = ['jp2 ', 'jpxb'] + + jpch = glymur.jp2box.CodestreamHeaderBox() + boxes.append(jpch) + jplh = glymur.jp2box.CompositingLayerHeaderBox() + boxes.append(jplh) + + with tempfile.NamedTemporaryFile(suffix=".jpx") as tfile: + jpx = jp2.wrap(tfile.name, boxes=boxes) + + self.assertEqual(jpx.box[-2].box_id, 'jpch') + self.assertEqual(jpx.box[-1].box_id, 'jplh') + def test_cgrp(self): """Write a color group box.""" jp2 = Jp2k(self.jp2file)