Fixed printing of cmap boxes when not pclr. #182
This commit is contained in:
parent
4d4ecac166
commit
c56b919c36
3 changed files with 22 additions and 1 deletions
|
|
@ -829,7 +829,7 @@ class ComponentMappingBox(Jp2kBox):
|
||||||
msg = msg.format(self.component_index[k],
|
msg = msg.format(self.component_index[k],
|
||||||
self.palette_index[k])
|
self.palette_index[k])
|
||||||
else:
|
else:
|
||||||
msg += '\n Component %d ==> %d'
|
msg += '\n Component {0} ==> {1}'
|
||||||
msg = msg.format(self.component_index[k], k)
|
msg = msg.format(self.component_index[k], k)
|
||||||
return msg
|
return msg
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -577,3 +577,8 @@ file1_xml = """XML Box (xml ) @ (36, 439)
|
||||||
\t\t<IMAGE_SOURCE>Professional 120 Image</IMAGE_SOURCE>
|
\t\t<IMAGE_SOURCE>Professional 120 Image</IMAGE_SOURCE>
|
||||||
\t</GENERAL_CREATION_INFO>
|
\t</GENERAL_CREATION_INFO>
|
||||||
</IMAGE_CREATION>"""
|
</IMAGE_CREATION>"""
|
||||||
|
|
||||||
|
issue_182_cmap = """Component Mapping Box (cmap) @ (130, 24)
|
||||||
|
Component 0 ==> palette column 0
|
||||||
|
Component 1 ==> palette column 0
|
||||||
|
Component 2 ==> 2"""
|
||||||
|
|
|
||||||
|
|
@ -905,6 +905,22 @@ class TestPrinting(unittest.TestCase):
|
||||||
expected = '\n'.join(lines)
|
expected = '\n'.join(lines)
|
||||||
self.assertEqual(actual, expected)
|
self.assertEqual(actual, expected)
|
||||||
|
|
||||||
|
def test_issue182(self):
|
||||||
|
"""Should not show the format string in output."""
|
||||||
|
# The cmap box is wildly broken, but printing was still wrong.
|
||||||
|
# Format strings like %d were showing up in the output.
|
||||||
|
filename = opj_data_file('input/nonregression/mem-b2ace68c-1381.jp2')
|
||||||
|
|
||||||
|
with warnings.catch_warnings():
|
||||||
|
# Ignore warning about bad pclr box.
|
||||||
|
warnings.simplefilter("ignore")
|
||||||
|
jp2 = Jp2k(filename)
|
||||||
|
with patch('sys.stdout', new=StringIO()) as fake_out:
|
||||||
|
print(jp2.box[3].box[3])
|
||||||
|
actual = fake_out.getvalue().strip()
|
||||||
|
self.assertEqual(actual, fixtures.issue_182_cmap)
|
||||||
|
|
||||||
|
|
||||||
@unittest.skipIf(sys.hexversion < 0x03000000,
|
@unittest.skipIf(sys.hexversion < 0x03000000,
|
||||||
"Ordered dicts not printing well in 2.7")
|
"Ordered dicts not printing well in 2.7")
|
||||||
def test_exif_uuid(self):
|
def test_exif_uuid(self):
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue