Check for supplying cinema2k/4k with other options. #139

This commit is contained in:
John Evans 2014-03-08 07:46:12 -05:00
commit 47b8dad003
2 changed files with 27 additions and 2 deletions

View file

@ -422,6 +422,10 @@ class Jp2k(Jp2kBox):
Either CLRSPC_SRGB or CLRSPC_GRAY
"""
if ('cinema2k' in kwargs or 'cinema4k' in kwargs) and len(set(kwargs)) > 1:
msg = "Cannot specify cinema2k/cinema4k along with other options."
raise IOError(msg)
if 'cratios' in kwargs and 'psnr' in kwargs:
msg = "Cannot specify cratios and psnr together."
raise IOError(msg)

View file

@ -35,8 +35,8 @@ import glymur
class TestSuiteWrite(unittest.TestCase):
"""Tests for writing with openjp2 backend.
These tests roughly correspond with those tests with similar names in the
OpenJPEG test suite.
These tests either roughly correspond with those tests with similar names
in the OpenJPEG test suite or are closely associated.
"""
def setUp(self):
pass
@ -44,6 +44,26 @@ class TestSuiteWrite(unittest.TestCase):
def tearDown(self):
pass
def test_cinema2K_with_others(self):
"""Can't specify cinema2k with any other options."""
relfile = 'input/nonregression/X_5_2K_24_235_CBR_STEM24_000.tif'
infile = opj_data_file(relfile)
data = skimage.io.imread(infile)
with tempfile.NamedTemporaryFile(suffix='.j2k') as tfile:
j = Jp2k(tfile.name, 'wb')
with self.assertRaises(IOError):
j.write(data, cinema2k=48, cratios=[200, 100, 50])
def test_cinema4K_with_others(self):
"""Can't specify cinema4k with any other options."""
relfile = 'input/nonregression/ElephantDream_4K.tif'
infile = opj_data_file(relfile)
data = skimage.io.imread(infile)
with tempfile.NamedTemporaryFile(suffix='.j2k') as tfile:
j = Jp2k(tfile.name, 'wb')
with self.assertRaises(IOError):
j.write(data, cinema4k=True, cratios=[200, 100, 50])
def check_cinema4k_codestream(self, codestream, image_size):
"""Common out for cinema2k tests."""
# SIZ: Image and tile size
@ -1052,5 +1072,6 @@ class TestSuiteWrite(unittest.TestCase):
glymur.core.WAVELET_XFORM_5X3_REVERSIBLE)
self.assertEqual(len(codestream.segment[2].spcod), 9)
if __name__ == "__main__":
unittest.main()