This commit is contained in:
jevans 2013-08-12 20:31:48 -04:00
commit 6f964ce146
2 changed files with 12 additions and 1 deletions

View file

@ -238,7 +238,7 @@ class Jp2k(Jp2kBox):
outfile += b'0' * num_pad_bytes
cparams.outfile = outfile
if self.filename[-4:].lower() == '.jp2':
if self.filename[-4:].endswith(('.jp2', '.JP2')):
cparams.codec_fmt = opj2.CODEC_JP2
else:
cparams.codec_fmt = opj2.CODEC_J2K

View file

@ -224,6 +224,17 @@ class TestJp2k(unittest.TestCase):
filename = 'this file does not actually exist on the file system.'
Jp2k(filename)
@unittest.skipIf(os.name == "nt", "NamedTemporaryFile issue on windows")
def test_write_with_JP2_suffix(self):
"""should be able to write with JP2 suffix."""
j2k = Jp2k(self.j2kfile)
expdata = j2k.read()
with tempfile.NamedTemporaryFile(suffix='.JP2') as tfile:
ofile = Jp2k(tfile.name, 'wb')
ofile.write(expdata)
actdata = ofile.read()
np.testing.assert_array_equal(actdata, expdata)
@unittest.skipIf(os.name == "nt", "NamedTemporaryFile issue on windows")
def test_write_srgb_without_mct(self):
"""should be able to write RGB without specifying mct"""