diff --git a/glymur/jp2k.py b/glymur/jp2k.py
index fbbf999..d159fcc 100644
--- a/glymur/jp2k.py
+++ b/glymur/jp2k.py
@@ -1293,11 +1293,12 @@ def _validate_jpx_compatibility(boxes, compatibility_list):
"""
If there is a JPX box then the compatibility list must also contain 'jpx '.
"""
+ jpx_cl = set(compatibility_list)
for box in boxes:
if box.box_id in JPX_IDS:
- if 'jpx ' not in compatibility_list:
- msg = "A JPX box requires that 'jpx ' be present in the "
- msg += "ftype compatibility list."
+ if len(set(['jpx ', 'jpxb']).intersection(jpx_cl)) == 0:
+ msg = "A JPX box requires that either 'jpx ' or 'jpxb' be "
+ msg += "present in the ftype compatibility list."
raise RuntimeError(msg)
if hasattr(box, 'box') != 0:
# Same set of checks on any child boxes.
diff --git a/glymur/test/test_jp2box_jpx.py b/glymur/test/test_jp2box_jpx.py
index 93b821f..2ebeb1f 100644
--- a/glymur/test/test_jp2box_jpx.py
+++ b/glymur/test/test_jp2box_jpx.py
@@ -40,6 +40,33 @@ class TestJPXWrap(unittest.TestCase):
def tearDown(self):
os.unlink(self.xmlfile)
+ def test_jpxb_compatibility(self):
+ """Wrap JP2 to JPX, state jpxb compatibility"""
+ jp2 = Jp2k(self.jp2file)
+ boxes = [jp2.box[idx] for idx in [0, 1, 2, 4]]
+
+ # The ftyp box must be modified to jpx with jp2 compatibility.
+ boxes[1].brand = 'jpx '
+ boxes[1].compatibility_list = ['jp2 ', 'jpxb']
+
+ numbers = (0, 1)
+ nlst = glymur.jp2box.NumberListBox(numbers)
+ the_xml = ET.fromstring('0')
+ xmlb = glymur.jp2box.XMLBox(xml=the_xml)
+ asoc = glymur.jp2box.AssociationBox([nlst, xmlb])
+ boxes.append(asoc)
+
+ with tempfile.NamedTemporaryFile(suffix=".jpx") as tfile:
+ jpx = jp2.wrap(tfile.name, boxes=boxes)
+
+ self.assertEqual(jpx.box[1].compatibility_list, ['jp2 ', 'jpxb'])
+ self.assertEqual(jpx.box[-1].box_id, 'asoc')
+ self.assertEqual(jpx.box[-1].box[0].box_id, 'nlst')
+ self.assertEqual(jpx.box[-1].box[1].box_id, 'xml ')
+ self.assertEqual(jpx.box[-1].box[0].associations, numbers)
+ self.assertEqual(ET.tostring(jpx.box[-1].box[1].xml.getroot()),
+ b'0')
+
def test_association_box(self):
"""Wrap JP2 to JPX with asoc(nlst, xml)"""
jp2 = Jp2k(self.jp2file)