diff --git a/glymur/jp2box.py b/glymur/jp2box.py index d4a44e9..aa92f2a 100644 --- a/glymur/jp2box.py +++ b/glymur/jp2box.py @@ -59,6 +59,11 @@ class Jp2kBox(object): msg += " @ ({0}, {1})".format(self.offset, self.length) return msg + def _write(self, f): + """Must be implemented in a subclass. + """ + raise NotImplementedError("Not supported for this box.") + def _parse_superbox(self, f): """Parse a superbox (box consisting of nothing but other boxes. @@ -882,8 +887,10 @@ class JPEG2000SignatureBox(Jp2kBox): Four-byte tuple identifying the file as JPEG 2000. """ def __init__(self, **kwargs): - Jp2kBox.__init__(self, id='', longname='JPEG 2000 Signature') + Jp2kBox.__init__(self, id='jP ', longname='JPEG 2000 Signature') self.__dict__.update(**kwargs) + if 'signature' not in kwargs.keys(): + self.signature = (13, 10, 135, 10) def __str__(self): msg = Jp2kBox.__str__(self) diff --git a/glymur/test/test_jp2box.py b/glymur/test/test_jp2box.py new file mode 100644 index 0000000..40b85b8 --- /dev/null +++ b/glymur/test/test_jp2box.py @@ -0,0 +1,27 @@ +import unittest + +import numpy as np +import pkg_resources + +import glymur + +@unittest.skipIf(glymur.lib.openjp2._OPENJP2 is None, + "Missing openjp2 library.") +class TestJp2Boxes(unittest.TestCase): + + def setUp(self): + self.jp2file = pkg_resources.resource_filename(glymur.__name__, + "data/nemo.jp2") + + def tearDown(self): + pass + + def test_default_JPEG2000SignatureBox(self): + # Should be able to instantiate a JPEG2000SignatureBox + b = glymur.jp2box.JPEG2000SignatureBox() + self.assertEqual(b.signature, (13, 10, 135, 10)) + + +if __name__ == "__main__": + unittest.main() +