Added 'jpxb' to accepted items in the ftyp compatibility list. #172
This commit is contained in:
parent
5ae5ce209b
commit
1906bb6004
2 changed files with 31 additions and 3 deletions
|
|
@ -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.
|
||||
|
|
|
|||
|
|
@ -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('<?xml version="1.0"?><data>0</data>')
|
||||
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'<data>0</data>')
|
||||
|
||||
def test_association_box(self):
|
||||
"""Wrap JP2 to JPX with asoc(nlst, xml)"""
|
||||
jp2 = Jp2k(self.jp2file)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue