Closes #101
This commit is contained in:
parent
4db8763056
commit
6f964ce146
2 changed files with 12 additions and 1 deletions
|
|
@ -238,7 +238,7 @@ class Jp2k(Jp2kBox):
|
||||||
outfile += b'0' * num_pad_bytes
|
outfile += b'0' * num_pad_bytes
|
||||||
cparams.outfile = outfile
|
cparams.outfile = outfile
|
||||||
|
|
||||||
if self.filename[-4:].lower() == '.jp2':
|
if self.filename[-4:].endswith(('.jp2', '.JP2')):
|
||||||
cparams.codec_fmt = opj2.CODEC_JP2
|
cparams.codec_fmt = opj2.CODEC_JP2
|
||||||
else:
|
else:
|
||||||
cparams.codec_fmt = opj2.CODEC_J2K
|
cparams.codec_fmt = opj2.CODEC_J2K
|
||||||
|
|
|
||||||
|
|
@ -224,6 +224,17 @@ class TestJp2k(unittest.TestCase):
|
||||||
filename = 'this file does not actually exist on the file system.'
|
filename = 'this file does not actually exist on the file system.'
|
||||||
Jp2k(filename)
|
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")
|
@unittest.skipIf(os.name == "nt", "NamedTemporaryFile issue on windows")
|
||||||
def test_write_srgb_without_mct(self):
|
def test_write_srgb_without_mct(self):
|
||||||
"""should be able to write RGB without specifying mct"""
|
"""should be able to write RGB without specifying mct"""
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue