Merge branch 'issue110' into devel

This commit is contained in:
John Evans 2013-09-07 07:38:34 -04:00
commit 83fe9e2a61
13 changed files with 1444 additions and 2470 deletions

View file

@ -12,6 +12,11 @@ before_install:
# command to install dependencies # command to install dependencies
install: install:
- pip install . --use-mirrors - pip install . --use-mirrors
# command to run tests # command to run tests
script: script:
- "python -m unittest discover" - "python -m unittest discover"
notifications:
email:
- john.g.evans.ne@gmail.com

View file

@ -1,3 +1,5 @@
Aug 21, 2013 - v0.4.1 Fixed segfault with openjpeg 1.x when rlevel=-1
Aug 18, 2013 - v0.4.0 Added append method. Aug 18, 2013 - v0.4.0 Added append method.
Aug 15, 2013 - v0.3.2 Fixed test bug where missing Pillow package caused test Aug 15, 2013 - v0.3.2 Fixed test bug where missing Pillow package caused test

View file

@ -78,7 +78,7 @@ copyright = u'2013, John Evans'
# The short X.Y version. # The short X.Y version.
version = '0.4' version = '0.4'
# The full version, including alpha/beta/rc tags. # The full version, including alpha/beta/rc tags.
release = '0.4.0' release = '0.4.1'
# The language for content autogenerated by Sphinx. Refer to documentation # The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages. # for a list of supported languages.

View file

@ -137,13 +137,14 @@ In addition, you must install contextlib2 and Pillow via pip. ::
Windows Windows
------- -------
32-bit WinPython 2.7.5 seems to work with OpenJPEG 1.X, 2.0, and the 32-bit WinPython 2.7.5 seemed to work with OpenJPEG 1.X, 2.0, and the
development version, but still requires contextlib2 and mock to be development version, but still required contextlib2 and mock to be
installed via pip. WinPython 3.3.2, however, seems to have trouble installed via pip. WinPython 3.3.2, however, seems to have trouble
with OpenJPEG 2.0, so I would suggest using the development version with OpenJPEG 2.0, so I would suggest using the development version
there (I'm unwilling to spend ANY more time trying to figure out what there (I'm unwilling to spend ANY more time trying to figure out what
the problem is there). the problem is there).
At the moment I do not have access to a win32 machine, and
64-bit windows is completely untested. 64-bit windows is completely untested.

View file

@ -55,8 +55,7 @@ Consider the following XML file `data.xml` : ::
</locality> </locality>
</info> </info>
The **append** method can add an XML box (only XML boxes are currently The **append** method can add an XML box as shown below::
allowed)::
>>> import shutil >>> import shutil
>>> import glymur >>> import glymur
@ -108,8 +107,8 @@ two additional boxes (image header and color specification) contained in the
JP2 header superbox. JP2 header superbox.
XML boxes are not in the minimal set of box requirements for the JP2 format, so XML boxes are not in the minimal set of box requirements for the JP2 format, so
in order to add an XML box into the mix, we'll need to specify all of the in order to add an XML box into the mix before the codestream box, we'll need to
boxes. If you already have a JP2 jacket in place, you can just reuse it, re-specify all of the boxes. If you already have a JP2 jacket in place, you can just reuse that,
though. Take the following example content in an XML file `favorites.xml` : :: though. Take the following example content in an XML file `favorites.xml` : ::
<?xml version="1.0"?> <?xml version="1.0"?>
@ -117,7 +116,8 @@ though. Take the following example content in an XML file `favorites.xml` : ::
<category>Light Ale</category> <category>Light Ale</category>
</favorite_things> </favorite_things>
and add it after the JP2 header box, but before the codestream box :: In order to add the XML after the JP2 header box, but before the codestream box,
the following will work. ::
>>> boxes = jp2.box # The box attribute is the list of JP2 boxes >>> boxes = jp2.box # The box attribute is the list of JP2 boxes
>>> xmlbox = glymur.jp2box.XMLBox(filename='favorites.xml') >>> xmlbox = glymur.jp2box.XMLBox(filename='favorites.xml')

View file

@ -1,6 +1,7 @@
""" """
Test fixtures common to more than one test point. Test fixtures common to more than one test point.
""" """
import os
import re import re
import sys import sys
import warnings import warnings
@ -9,10 +10,12 @@ import numpy as np
import glymur import glymur
# Need to know the openjpeg version. If openjpeg is not installed, we use # Need to know the version of the openjpeg software. If openjpeg is not
# '0.0.0' # installed, we use # '0.0.0'
OPENJPEG_VERSION = '0.0.0' OPENJPEG_VERSION = '0.0.0'
if glymur.lib.openjpeg.OPENJPEG is not None: if glymur.lib.openjp2.OPENJP2 is not None:
OPENJPEG_VERSION = glymur.lib.openjp2.version()
elif glymur.lib.openjpeg.OPENJPEG is not None:
OPENJPEG_VERSION = glymur.lib.openjpeg.version() OPENJPEG_VERSION = glymur.lib.openjpeg.version()
# Need to know of the libopenjp2 version is the official 2.0.0 release and NOT # Need to know of the libopenjp2 version is the official 2.0.0 release and NOT
@ -27,6 +30,19 @@ if glymur.lib.openjp2.OPENJP2 is not None:
NO_READ_BACKEND_MSG = "Matplotlib with the PIL backend must be available in " NO_READ_BACKEND_MSG = "Matplotlib with the PIL backend must be available in "
NO_READ_BACKEND_MSG += "order to run the tests in this suite." NO_READ_BACKEND_MSG += "order to run the tests in this suite."
try:
OPJ_DATA_ROOT = os.environ['OPJ_DATA_ROOT']
except KeyError:
OPJ_DATA_ROOT = None
except:
raise
def opj_data_file(relative_file_name):
"""Compact way of forming a full filename from OpenJPEG's test suite."""
jfile = os.path.join(OPJ_DATA_ROOT, relative_file_name)
return jfile
try: try:
from matplotlib.pyplot import imread from matplotlib.pyplot import imread

View file

@ -20,16 +20,10 @@ else:
import numpy as np import numpy as np
from glymur import Jp2k from glymur import Jp2k
from .fixtures import OPJ_DATA_ROOT, opj_data_file
try:
DATA_ROOT = os.environ['OPJ_DATA_ROOT']
except KeyError:
DATA_ROOT = None
except:
raise
@unittest.skipIf(DATA_ROOT is None, @unittest.skipIf(OPJ_DATA_ROOT is None,
"OPJ_DATA_ROOT environment variable not set") "OPJ_DATA_ROOT environment variable not set")
class TestICC(unittest.TestCase): class TestICC(unittest.TestCase):
"""ICC profile tests""" """ICC profile tests"""
@ -42,7 +36,7 @@ class TestICC(unittest.TestCase):
def test_file5(self): def test_file5(self):
"""basic ICC profile""" """basic ICC profile"""
filename = os.path.join(DATA_ROOT, 'input/conformance/file5.jp2') filename = opj_data_file('input/conformance/file5.jp2')
j = Jp2k(filename) j = Jp2k(filename)
profile = j.box[3].box[1].icc_profile profile = j.box[3].box[1].icc_profile
self.assertEqual(profile['Size'], 546) self.assertEqual(profile['Size'], 546)
@ -75,8 +69,7 @@ class TestICC(unittest.TestCase):
"Uses features introduced in 3.2.") "Uses features introduced in 3.2.")
def test_invalid_profile_header(self): def test_invalid_profile_header(self):
"""invalid ICC header data should cause UserWarning""" """invalid ICC header data should cause UserWarning"""
jfile = os.path.join(DATA_ROOT, jfile = opj_data_file('input/nonregression/orb-blue10-lin-jp2.jp2')
'input/nonregression/orb-blue10-lin-jp2.jp2')
# assertWarns in Python 3.3 (python2.7/pylint issue) # assertWarns in Python 3.3 (python2.7/pylint issue)
# pylint: disable=E1101 # pylint: disable=E1101

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -23,23 +23,17 @@ else:
import numpy as np import numpy as np
from .fixtures import read_image, NO_READ_BACKEND, NO_READ_BACKEND_MSG from .fixtures import read_image, NO_READ_BACKEND, NO_READ_BACKEND_MSG
from .fixtures import OPJ_DATA_ROOT, opj_data_file
from glymur import Jp2k from glymur import Jp2k
import glymur import glymur
try:
DATA_ROOT = os.environ['OPJ_DATA_ROOT']
except KeyError:
DATA_ROOT = None
except:
raise
@unittest.skipIf(glymur.lib.openjp2.OPENJP2 is None, @unittest.skipIf(glymur.lib.openjp2.OPENJP2 is None,
"Missing openjp2 library.") "Missing openjp2 library.")
@unittest.skipIf(NO_READ_BACKEND, NO_READ_BACKEND_MSG) @unittest.skipIf(NO_READ_BACKEND, NO_READ_BACKEND_MSG)
@unittest.skipIf(DATA_ROOT is None, @unittest.skipIf(OPJ_DATA_ROOT is None,
"OPJ_DATA_ROOT environment variable not set") "OPJ_OPJ_DATA_ROOT environment variable not set")
class TestSuiteNegative(unittest.TestCase): class TestSuiteNegative(unittest.TestCase):
"""Test suite for certain negative tests from openjpeg suite.""" """Test suite for certain negative tests from openjpeg suite."""
@ -54,7 +48,7 @@ class TestSuiteNegative(unittest.TestCase):
def test_psnr_with_cratios(self): def test_psnr_with_cratios(self):
"""Using psnr with cratios options is not allowed.""" """Using psnr with cratios options is not allowed."""
# Not an OpenJPEG test, but close. # Not an OpenJPEG test, but close.
infile = os.path.join(DATA_ROOT, 'input/nonregression/Bretagne1.ppm') infile = opj_data_file('input/nonregression/Bretagne1.ppm')
data = read_image(infile) data = read_image(infile)
with tempfile.NamedTemporaryFile(suffix='.j2k') as tfile: with tempfile.NamedTemporaryFile(suffix='.j2k') as tfile:
j = Jp2k(tfile.name, 'wb') j = Jp2k(tfile.name, 'wb')
@ -64,7 +58,7 @@ class TestSuiteNegative(unittest.TestCase):
def test_nr_marker_not_compliant(self): def test_nr_marker_not_compliant(self):
"""non-compliant marker, should still be able to read""" """non-compliant marker, should still be able to read"""
relpath = 'input/nonregression/MarkerIsNotCompliant.j2k' relpath = 'input/nonregression/MarkerIsNotCompliant.j2k'
jfile = os.path.join(DATA_ROOT, relpath) jfile = opj_data_file(relpath)
jp2k = Jp2k(jfile) jp2k = Jp2k(jfile)
jp2k.get_codestream(header_only=False) jp2k.get_codestream(header_only=False)
self.assertTrue(True) self.assertTrue(True)
@ -74,7 +68,7 @@ class TestSuiteNegative(unittest.TestCase):
def test_nr_illegalclrtransform(self): def test_nr_illegalclrtransform(self):
"""EOC marker is bad""" """EOC marker is bad"""
relpath = 'input/nonregression/illegalcolortransform.j2k' relpath = 'input/nonregression/illegalcolortransform.j2k'
jfile = os.path.join(DATA_ROOT, relpath) jfile = opj_data_file(relpath)
jp2k = Jp2k(jfile) jp2k = Jp2k(jfile)
with self.assertWarns(UserWarning): with self.assertWarns(UserWarning):
codestream = jp2k.get_codestream(header_only=False) codestream = jp2k.get_codestream(header_only=False)
@ -87,7 +81,7 @@ class TestSuiteNegative(unittest.TestCase):
def test_nr_cannotreadwnosizeknown(self): def test_nr_cannotreadwnosizeknown(self):
"""not sure exactly what is wrong with this file""" """not sure exactly what is wrong with this file"""
relpath = 'input/nonregression/Cannotreaddatawithnosizeknown.j2k' relpath = 'input/nonregression/Cannotreaddatawithnosizeknown.j2k'
jfile = os.path.join(DATA_ROOT, relpath) jfile = opj_data_file(relpath)
jp2k = Jp2k(jfile) jp2k = Jp2k(jfile)
jp2k.get_codestream(header_only=False) jp2k.get_codestream(header_only=False)
self.assertTrue(True) self.assertTrue(True)
@ -118,7 +112,7 @@ class TestSuiteNegative(unittest.TestCase):
# Verify that a warning is issued if we read past the end of a box # Verify that a warning is issued if we read past the end of a box
# This file has a palette (pclr) box whose length is impossibly # This file has a palette (pclr) box whose length is impossibly
# short. # short.
infile = os.path.join(DATA_ROOT, infile = os.path.join(OPJ_DATA_ROOT,
'input/nonregression/mem-b2ace68c-1381.jp2') 'input/nonregression/mem-b2ace68c-1381.jp2')
with self.assertWarns(UserWarning): with self.assertWarns(UserWarning):
Jp2k(infile) Jp2k(infile)

View file

@ -19,23 +19,17 @@ else:
import unittest import unittest
from .fixtures import read_image, NO_READ_BACKEND, NO_READ_BACKEND_MSG from .fixtures import read_image, NO_READ_BACKEND, NO_READ_BACKEND_MSG
from .fixtures import OPJ_DATA_ROOT, opj_data_file
from glymur import Jp2k from glymur import Jp2k
import glymur import glymur
try:
data_root = os.environ['OPJ_DATA_ROOT']
except KeyError:
data_root = None
except:
raise
@unittest.skipIf(os.name == "nt", "no write support on windows, period") @unittest.skipIf(os.name == "nt", "no write support on windows, period")
@unittest.skipIf(glymur.lib.openjp2.OPENJP2 is None, @unittest.skipIf(glymur.lib.openjp2.OPENJP2 is None,
"Missing openjp2 library.") "Missing openjp2 library.")
@unittest.skipIf(NO_READ_BACKEND, NO_READ_BACKEND_MSG) @unittest.skipIf(NO_READ_BACKEND, NO_READ_BACKEND_MSG)
@unittest.skipIf(data_root is None, @unittest.skipIf(OPJ_DATA_ROOT is None,
"OPJ_DATA_ROOT environment variable not set") "OPJ_DATA_ROOT environment variable not set")
class TestSuiteWrite(unittest.TestCase): class TestSuiteWrite(unittest.TestCase):
"""Tests for writing with openjp2 backend. """Tests for writing with openjp2 backend.
@ -51,7 +45,7 @@ class TestSuiteWrite(unittest.TestCase):
def test_NR_ENC_Bretagne1_ppm_1_encode(self): def test_NR_ENC_Bretagne1_ppm_1_encode(self):
"""NR-ENC-Bretagne1.ppm-1-encode""" """NR-ENC-Bretagne1.ppm-1-encode"""
infile = os.path.join(data_root, 'input/nonregression/Bretagne1.ppm') infile = opj_data_file('input/nonregression/Bretagne1.ppm')
data = read_image(infile) data = read_image(infile)
with tempfile.NamedTemporaryFile(suffix='.j2k') as tfile: with tempfile.NamedTemporaryFile(suffix='.j2k') as tfile:
j = Jp2k(tfile.name, 'wb') j = Jp2k(tfile.name, 'wb')
@ -115,7 +109,7 @@ class TestSuiteWrite(unittest.TestCase):
def test_NR_ENC_Bretagne1_ppm_2_encode(self): def test_NR_ENC_Bretagne1_ppm_2_encode(self):
"""NR-ENC-Bretagne1.ppm-2-encode""" """NR-ENC-Bretagne1.ppm-2-encode"""
infile = os.path.join(data_root, 'input/nonregression/Bretagne1.ppm') infile = opj_data_file('input/nonregression/Bretagne1.ppm')
data = read_image(infile) data = read_image(infile)
with tempfile.NamedTemporaryFile(suffix='.j2k') as tfile: with tempfile.NamedTemporaryFile(suffix='.j2k') as tfile:
j = Jp2k(tfile.name, 'wb') j = Jp2k(tfile.name, 'wb')
@ -180,7 +174,7 @@ class TestSuiteWrite(unittest.TestCase):
def test_NR_ENC_Bretagne1_ppm_3_encode(self): def test_NR_ENC_Bretagne1_ppm_3_encode(self):
"""NR-ENC-Bretagne1.ppm-3-encode""" """NR-ENC-Bretagne1.ppm-3-encode"""
infile = os.path.join(data_root, 'input/nonregression/Bretagne1.ppm') infile = opj_data_file('input/nonregression/Bretagne1.ppm')
data = read_image(infile) data = read_image(infile)
with tempfile.NamedTemporaryFile(suffix='.j2k') as tfile: with tempfile.NamedTemporaryFile(suffix='.j2k') as tfile:
j = Jp2k(tfile.name, 'wb') j = Jp2k(tfile.name, 'wb')
@ -247,7 +241,7 @@ class TestSuiteWrite(unittest.TestCase):
def test_NR_ENC_Bretagne2_ppm_4_encode(self): def test_NR_ENC_Bretagne2_ppm_4_encode(self):
"""NR-ENC-Bretagne2.ppm-4-encode""" """NR-ENC-Bretagne2.ppm-4-encode"""
infile = os.path.join(data_root, 'input/nonregression/Bretagne2.ppm') infile = opj_data_file('input/nonregression/Bretagne2.ppm')
data = read_image(infile) data = read_image(infile)
with tempfile.NamedTemporaryFile(suffix='.j2k') as tfile: with tempfile.NamedTemporaryFile(suffix='.j2k') as tfile:
j = Jp2k(tfile.name, 'wb') j = Jp2k(tfile.name, 'wb')
@ -316,7 +310,7 @@ class TestSuiteWrite(unittest.TestCase):
def test_NR_ENC_Bretagne2_ppm_5_encode(self): def test_NR_ENC_Bretagne2_ppm_5_encode(self):
"""NR-ENC-Bretagne2.ppm-5-encode""" """NR-ENC-Bretagne2.ppm-5-encode"""
infile = os.path.join(data_root, 'input/nonregression/Bretagne2.ppm') infile = opj_data_file('input/nonregression/Bretagne2.ppm')
data = read_image(infile) data = read_image(infile)
with tempfile.NamedTemporaryFile(suffix='.j2k') as tfile: with tempfile.NamedTemporaryFile(suffix='.j2k') as tfile:
j = Jp2k(tfile.name, 'wb') j = Jp2k(tfile.name, 'wb')
@ -379,7 +373,7 @@ class TestSuiteWrite(unittest.TestCase):
def test_NR_ENC_Bretagne2_ppm_6_encode(self): def test_NR_ENC_Bretagne2_ppm_6_encode(self):
"""NR-ENC-Bretagne2.ppm-6-encode""" """NR-ENC-Bretagne2.ppm-6-encode"""
infile = os.path.join(data_root, 'input/nonregression/Bretagne2.ppm') infile = opj_data_file('input/nonregression/Bretagne2.ppm')
data = read_image(infile) data = read_image(infile)
with tempfile.NamedTemporaryFile(suffix='.j2k') as tfile: with tempfile.NamedTemporaryFile(suffix='.j2k') as tfile:
j = Jp2k(tfile.name, 'wb') j = Jp2k(tfile.name, 'wb')
@ -447,7 +441,7 @@ class TestSuiteWrite(unittest.TestCase):
def test_NR_ENC_Bretagne2_ppm_7_encode(self): def test_NR_ENC_Bretagne2_ppm_7_encode(self):
"""NR-ENC-Bretagne2.ppm-7-encode""" """NR-ENC-Bretagne2.ppm-7-encode"""
infile = os.path.join(data_root, 'input/nonregression/Bretagne2.ppm') infile = opj_data_file('input/nonregression/Bretagne2.ppm')
data = read_image(infile) data = read_image(infile)
with tempfile.NamedTemporaryFile(suffix='.j2k') as tfile: with tempfile.NamedTemporaryFile(suffix='.j2k') as tfile:
j = Jp2k(tfile.name, 'wb') j = Jp2k(tfile.name, 'wb')
@ -514,7 +508,7 @@ class TestSuiteWrite(unittest.TestCase):
def test_NR_ENC_Bretagne2_ppm_8_encode(self): def test_NR_ENC_Bretagne2_ppm_8_encode(self):
"""NR-ENC-Bretagne2.ppm-8-encode""" """NR-ENC-Bretagne2.ppm-8-encode"""
infile = os.path.join(data_root, 'input/nonregression/Bretagne2.ppm') infile = opj_data_file('input/nonregression/Bretagne2.ppm')
data = read_image(infile) data = read_image(infile)
with tempfile.NamedTemporaryFile(suffix='.j2k') as tfile: with tempfile.NamedTemporaryFile(suffix='.j2k') as tfile:
j = Jp2k(tfile.name, 'wb') j = Jp2k(tfile.name, 'wb')
@ -578,7 +572,7 @@ class TestSuiteWrite(unittest.TestCase):
def test_NR_ENC_Cevennes1_bmp_9_encode(self): def test_NR_ENC_Cevennes1_bmp_9_encode(self):
"""NR-ENC-Cevennes1.bmp-9-encode""" """NR-ENC-Cevennes1.bmp-9-encode"""
infile = os.path.join(data_root, 'input/nonregression/Cevennes1.bmp') infile = opj_data_file('input/nonregression/Cevennes1.bmp')
data = read_image(infile) data = read_image(infile)
with tempfile.NamedTemporaryFile(suffix='.j2k') as tfile: with tempfile.NamedTemporaryFile(suffix='.j2k') as tfile:
j = Jp2k(tfile.name, 'wb') j = Jp2k(tfile.name, 'wb')
@ -641,7 +635,7 @@ class TestSuiteWrite(unittest.TestCase):
def test_NR_ENC_Cevennes2_ppm_10_encode(self): def test_NR_ENC_Cevennes2_ppm_10_encode(self):
"""NR-ENC-Cevennes2.ppm-10-encode""" """NR-ENC-Cevennes2.ppm-10-encode"""
infile = os.path.join(data_root, 'input/nonregression/Cevennes2.ppm') infile = opj_data_file('input/nonregression/Cevennes2.ppm')
data = read_image(infile) data = read_image(infile)
with tempfile.NamedTemporaryFile(suffix='.j2k') as tfile: with tempfile.NamedTemporaryFile(suffix='.j2k') as tfile:
j = Jp2k(tfile.name, 'wb') j = Jp2k(tfile.name, 'wb')
@ -704,8 +698,7 @@ class TestSuiteWrite(unittest.TestCase):
def test_NR_ENC_Rome_bmp_11_encode(self): def test_NR_ENC_Rome_bmp_11_encode(self):
"""NR-ENC-Rome.bmp-11-encode""" """NR-ENC-Rome.bmp-11-encode"""
data = read_image(os.path.join(data_root, data = read_image(opj_data_file('input/nonregression/Rome.bmp'))
'input/nonregression/Rome.bmp'))
with tempfile.NamedTemporaryFile(suffix='.jp2') as tfile: with tempfile.NamedTemporaryFile(suffix='.jp2') as tfile:
jp2 = Jp2k(tfile.name, 'wb') jp2 = Jp2k(tfile.name, 'wb')
jp2.write(data, psnr=[30, 35, 50], prog='LRCP', numres=3) jp2.write(data, psnr=[30, 35, 50], prog='LRCP', numres=3)
@ -804,8 +797,7 @@ class TestSuiteWrite(unittest.TestCase):
"""NR-ENC-random-issue-0005.tif-12-encode""" """NR-ENC-random-issue-0005.tif-12-encode"""
# opj_decompress has trouble reading it, but that is not an issue here. # opj_decompress has trouble reading it, but that is not an issue here.
# The nature of the image itself seems to give the compressor trouble. # The nature of the image itself seems to give the compressor trouble.
infile = os.path.join(data_root, infile = opj_data_file('input/nonregression/random-issue-0005.tif')
'input/nonregression/random-issue-0005.tif')
data = read_image(infile) data = read_image(infile)
with tempfile.NamedTemporaryFile(suffix='.j2k') as tfile: with tempfile.NamedTemporaryFile(suffix='.j2k') as tfile:
j = Jp2k(tfile.name, 'wb') j = Jp2k(tfile.name, 'wb')

View file

@ -32,13 +32,7 @@ else:
import glymur import glymur
from glymur import Jp2k from glymur import Jp2k
from .fixtures import OPJ_DATA_ROOT, opj_data_file
try:
DATA_ROOT = os.environ['OPJ_DATA_ROOT']
except KeyError:
DATA_ROOT = None
except:
raise
@unittest.skipIf(os.name == "nt", "Temporary file issue on window.") @unittest.skipIf(os.name == "nt", "Temporary file issue on window.")
@ -287,11 +281,11 @@ class TestPrinting(unittest.TestCase):
expected = '\n'.join(lines) expected = '\n'.join(lines)
self.assertEqual(actual, expected) self.assertEqual(actual, expected)
@unittest.skipIf(DATA_ROOT is None, @unittest.skipIf(OPJ_DATA_ROOT is None,
"OPJ_DATA_ROOT environment variable not set") "OPJ_DATA_ROOT environment variable not set")
def test_icc_profile(self): def test_icc_profile(self):
"""verify printing of colr box with ICC profile""" """verify printing of colr box with ICC profile"""
filename = os.path.join(DATA_ROOT, 'input/nonregression/text_GBR.jp2') filename = opj_data_file('input/nonregression/text_GBR.jp2')
with warnings.catch_warnings(): with warnings.catch_warnings():
# brand is 'jp2 ', but has any icc profile. # brand is 'jp2 ', but has any icc profile.
warnings.simplefilter("ignore") warnings.simplefilter("ignore")
@ -356,11 +350,11 @@ class TestPrinting(unittest.TestCase):
expected = '\n'.join(lines) expected = '\n'.join(lines)
self.assertEqual(actual, expected) self.assertEqual(actual, expected)
@unittest.skipIf(DATA_ROOT is None, @unittest.skipIf(OPJ_DATA_ROOT is None,
"OPJ_DATA_ROOT environment variable not set") "OPJ_DATA_ROOT environment variable not set")
def test_crg(self): def test_crg(self):
"""verify printing of CRG segment""" """verify printing of CRG segment"""
filename = os.path.join(DATA_ROOT, 'input/conformance/p0_03.j2k') filename = opj_data_file('input/conformance/p0_03.j2k')
j = glymur.Jp2k(filename) j = glymur.Jp2k(filename)
codestream = j.get_codestream() codestream = j.get_codestream()
with patch('sys.stdout', new=StringIO()) as fake_out: with patch('sys.stdout', new=StringIO()) as fake_out:
@ -371,11 +365,11 @@ class TestPrinting(unittest.TestCase):
expected = '\n'.join(lines) expected = '\n'.join(lines)
self.assertEqual(actual, expected) self.assertEqual(actual, expected)
@unittest.skipIf(DATA_ROOT is None, @unittest.skipIf(OPJ_DATA_ROOT is None,
"OPJ_DATA_ROOT environment variable not set") "OPJ_DATA_ROOT environment variable not set")
def test_rgn(self): def test_rgn(self):
"""verify printing of RGN segment""" """verify printing of RGN segment"""
filename = os.path.join(DATA_ROOT, 'input/conformance/p0_03.j2k') filename = opj_data_file('input/conformance/p0_03.j2k')
j = glymur.Jp2k(filename) j = glymur.Jp2k(filename)
codestream = j.get_codestream(header_only=False) codestream = j.get_codestream(header_only=False)
with patch('sys.stdout', new=StringIO()) as fake_out: with patch('sys.stdout', new=StringIO()) as fake_out:
@ -388,11 +382,11 @@ class TestPrinting(unittest.TestCase):
expected = '\n'.join(lines) expected = '\n'.join(lines)
self.assertEqual(actual, expected) self.assertEqual(actual, expected)
@unittest.skipIf(DATA_ROOT is None, @unittest.skipIf(OPJ_DATA_ROOT is None,
"OPJ_DATA_ROOT environment variable not set") "OPJ_DATA_ROOT environment variable not set")
def test_sop(self): def test_sop(self):
"""verify printing of SOP segment""" """verify printing of SOP segment"""
filename = os.path.join(DATA_ROOT, 'input/conformance/p0_03.j2k') filename = opj_data_file('input/conformance/p0_03.j2k')
j = glymur.Jp2k(filename) j = glymur.Jp2k(filename)
codestream = j.get_codestream(header_only=False) codestream = j.get_codestream(header_only=False)
with patch('sys.stdout', new=StringIO()) as fake_out: with patch('sys.stdout', new=StringIO()) as fake_out:
@ -403,11 +397,11 @@ class TestPrinting(unittest.TestCase):
expected = '\n'.join(lines) expected = '\n'.join(lines)
self.assertEqual(actual, expected) self.assertEqual(actual, expected)
@unittest.skipIf(DATA_ROOT is None, @unittest.skipIf(OPJ_DATA_ROOT is None,
"OPJ_DATA_ROOT environment variable not set") "OPJ_DATA_ROOT environment variable not set")
def test_cme(self): def test_cme(self):
"""Test printing a CME or comment marker segment.""" """Test printing a CME or comment marker segment."""
filename = os.path.join(DATA_ROOT, 'input/conformance/p0_02.j2k') filename = opj_data_file('input/conformance/p0_02.j2k')
j = glymur.Jp2k(filename) j = glymur.Jp2k(filename)
codestream = j.get_codestream() codestream = j.get_codestream()
# 2nd to last segment in the main header # 2nd to last segment in the main header
@ -431,11 +425,11 @@ class TestPrinting(unittest.TestCase):
expected = '\n'.join(lines) expected = '\n'.join(lines)
self.assertEqual(actual, expected) self.assertEqual(actual, expected)
@unittest.skipIf(DATA_ROOT is None, @unittest.skipIf(OPJ_DATA_ROOT is None,
"OPJ_DATA_ROOT environment variable not set") "OPJ_DATA_ROOT environment variable not set")
def test_plt_segment(self): def test_plt_segment(self):
"""verify printing of PLT segment""" """verify printing of PLT segment"""
filename = os.path.join(DATA_ROOT, 'input/conformance/p0_07.j2k') filename = opj_data_file('input/conformance/p0_07.j2k')
j = glymur.Jp2k(filename) j = glymur.Jp2k(filename)
codestream = j.get_codestream(header_only=False) codestream = j.get_codestream(header_only=False)
with patch('sys.stdout', new=StringIO()) as fake_out: with patch('sys.stdout', new=StringIO()) as fake_out:
@ -450,11 +444,11 @@ class TestPrinting(unittest.TestCase):
expected = '\n'.join(lines) expected = '\n'.join(lines)
self.assertEqual(actual, expected) self.assertEqual(actual, expected)
@unittest.skipIf(DATA_ROOT is None, @unittest.skipIf(OPJ_DATA_ROOT is None,
"OPJ_DATA_ROOT environment variable not set") "OPJ_DATA_ROOT environment variable not set")
def test_pod_segment(self): def test_pod_segment(self):
"""verify printing of POD segment""" """verify printing of POD segment"""
filename = os.path.join(DATA_ROOT, 'input/conformance/p0_13.j2k') filename = opj_data_file('input/conformance/p0_13.j2k')
j = glymur.Jp2k(filename) j = glymur.Jp2k(filename)
codestream = j.get_codestream() codestream = j.get_codestream()
with patch('sys.stdout', new=StringIO()) as fake_out: with patch('sys.stdout', new=StringIO()) as fake_out:
@ -480,11 +474,11 @@ class TestPrinting(unittest.TestCase):
expected = '\n'.join(lines) expected = '\n'.join(lines)
self.assertEqual(actual, expected) self.assertEqual(actual, expected)
@unittest.skipIf(DATA_ROOT is None, @unittest.skipIf(OPJ_DATA_ROOT is None,
"OPJ_DATA_ROOT environment variable not set") "OPJ_DATA_ROOT environment variable not set")
def test_ppm_segment(self): def test_ppm_segment(self):
"""verify printing of PPM segment""" """verify printing of PPM segment"""
filename = os.path.join(DATA_ROOT, 'input/conformance/p1_03.j2k') filename = opj_data_file('input/conformance/p1_03.j2k')
j = glymur.Jp2k(filename) j = glymur.Jp2k(filename)
codestream = j.get_codestream() codestream = j.get_codestream()
with patch('sys.stdout', new=StringIO()) as fake_out: with patch('sys.stdout', new=StringIO()) as fake_out:
@ -498,11 +492,11 @@ class TestPrinting(unittest.TestCase):
expected = '\n'.join(lines) expected = '\n'.join(lines)
self.assertEqual(actual, expected) self.assertEqual(actual, expected)
@unittest.skipIf(DATA_ROOT is None, @unittest.skipIf(OPJ_DATA_ROOT is None,
"OPJ_DATA_ROOT environment variable not set") "OPJ_DATA_ROOT environment variable not set")
def test_ppt_segment(self): def test_ppt_segment(self):
"""verify printing of ppt segment""" """verify printing of ppt segment"""
filename = os.path.join(DATA_ROOT, 'input/conformance/p1_06.j2k') filename = opj_data_file('input/conformance/p1_06.j2k')
j = glymur.Jp2k(filename) j = glymur.Jp2k(filename)
codestream = j.get_codestream(header_only=False) codestream = j.get_codestream(header_only=False)
with patch('sys.stdout', new=StringIO()) as fake_out: with patch('sys.stdout', new=StringIO()) as fake_out:
@ -610,11 +604,11 @@ class TestPrinting(unittest.TestCase):
expected = '\n'.join(lines) expected = '\n'.join(lines)
self.assertEqual(actual, expected) self.assertEqual(actual, expected)
@unittest.skipIf(DATA_ROOT is None, @unittest.skipIf(OPJ_DATA_ROOT is None,
"OPJ_DATA_ROOT environment variable not set") "OPJ_DATA_ROOT environment variable not set")
def test_tlm_segment(self): def test_tlm_segment(self):
"""verify printing of TLM segment""" """verify printing of TLM segment"""
filename = os.path.join(DATA_ROOT, 'input/conformance/p0_15.j2k') filename = opj_data_file('input/conformance/p0_15.j2k')
j = glymur.Jp2k(filename) j = glymur.Jp2k(filename)
codestream = j.get_codestream() codestream = j.get_codestream()
with patch('sys.stdout', new=StringIO()) as fake_out: with patch('sys.stdout', new=StringIO()) as fake_out:
@ -704,11 +698,11 @@ class TestPrinting(unittest.TestCase):
@unittest.skipIf(sys.hexversion < 0x02070000, @unittest.skipIf(sys.hexversion < 0x02070000,
"Differences in XML printing between 2.6 and 2.7") "Differences in XML printing between 2.6 and 2.7")
@unittest.skipIf(DATA_ROOT is None, @unittest.skipIf(OPJ_DATA_ROOT is None,
"OPJ_DATA_ROOT environment variable not set") "OPJ_DATA_ROOT environment variable not set")
def test_xml(self): def test_xml(self):
"""verify printing of XML box""" """verify printing of XML box"""
filename = os.path.join(DATA_ROOT, 'input/conformance/file1.jp2') filename = opj_data_file('input/conformance/file1.jp2')
j = glymur.Jp2k(filename) j = glymur.Jp2k(filename)
with patch('sys.stdout', new=StringIO()) as fake_out: with patch('sys.stdout', new=StringIO()) as fake_out:
print(j.box[2]) print(j.box[2])
@ -735,11 +729,11 @@ class TestPrinting(unittest.TestCase):
expected = '\n'.join(lines) expected = '\n'.join(lines)
self.assertEqual(actual, expected) self.assertEqual(actual, expected)
@unittest.skipIf(DATA_ROOT is None, @unittest.skipIf(OPJ_DATA_ROOT is None,
"OPJ_DATA_ROOT environment variable not set") "OPJ_DATA_ROOT environment variable not set")
def test_channel_definition(self): def test_channel_definition(self):
"""verify printing of cdef box""" """verify printing of cdef box"""
filename = os.path.join(DATA_ROOT, 'input/conformance/file2.jp2') filename = opj_data_file('input/conformance/file2.jp2')
j = glymur.Jp2k(filename) j = glymur.Jp2k(filename)
with patch('sys.stdout', new=StringIO()) as fake_out: with patch('sys.stdout', new=StringIO()) as fake_out:
print(j.box[2].box[2]) print(j.box[2].box[2])
@ -751,11 +745,11 @@ class TestPrinting(unittest.TestCase):
expected = '\n'.join(lines) expected = '\n'.join(lines)
self.assertEqual(actual, expected) self.assertEqual(actual, expected)
@unittest.skipIf(DATA_ROOT is None, @unittest.skipIf(OPJ_DATA_ROOT is None,
"OPJ_DATA_ROOT environment variable not set") "OPJ_DATA_ROOT environment variable not set")
def test_component_mapping(self): def test_component_mapping(self):
"""verify printing of cmap box""" """verify printing of cmap box"""
filename = os.path.join(DATA_ROOT, 'input/conformance/file9.jp2') filename = opj_data_file('input/conformance/file9.jp2')
j = glymur.Jp2k(filename) j = glymur.Jp2k(filename)
with patch('sys.stdout', new=StringIO()) as fake_out: with patch('sys.stdout', new=StringIO()) as fake_out:
print(j.box[2].box[2]) print(j.box[2].box[2])
@ -767,11 +761,11 @@ class TestPrinting(unittest.TestCase):
expected = '\n'.join(lines) expected = '\n'.join(lines)
self.assertEqual(actual, expected) self.assertEqual(actual, expected)
@unittest.skipIf(DATA_ROOT is None, @unittest.skipIf(OPJ_DATA_ROOT is None,
"OPJ_DATA_ROOT environment variable not set") "OPJ_DATA_ROOT environment variable not set")
def test_palette7(self): def test_palette7(self):
"""verify printing of pclr box""" """verify printing of pclr box"""
filename = os.path.join(DATA_ROOT, 'input/conformance/file9.jp2') filename = opj_data_file('input/conformance/file9.jp2')
j = glymur.Jp2k(filename) j = glymur.Jp2k(filename)
with patch('sys.stdout', new=StringIO()) as fake_out: with patch('sys.stdout', new=StringIO()) as fake_out:
print(j.box[2].box[1]) print(j.box[2].box[1])
@ -781,11 +775,11 @@ class TestPrinting(unittest.TestCase):
expected = '\n'.join(lines) expected = '\n'.join(lines)
self.assertEqual(actual, expected) self.assertEqual(actual, expected)
@unittest.skipIf(DATA_ROOT is None, @unittest.skipIf(OPJ_DATA_ROOT is None,
"OPJ_DATA_ROOT environment variable not set") "OPJ_DATA_ROOT environment variable not set")
def test_rreq(self): def test_rreq(self):
"""verify printing of reader requirements box""" """verify printing of reader requirements box"""
filename = os.path.join(DATA_ROOT, 'input/conformance/file7.jp2') filename = opj_data_file('input/conformance/file7.jp2')
j = glymur.Jp2k(filename) j = glymur.Jp2k(filename)
with patch('sys.stdout', new=StringIO()) as fake_out: with patch('sys.stdout', new=StringIO()) as fake_out:
print(j.box[2]) print(j.box[2])
@ -805,11 +799,11 @@ class TestPrinting(unittest.TestCase):
expected = '\n'.join(lines) expected = '\n'.join(lines)
self.assertEqual(actual, expected) self.assertEqual(actual, expected)
@unittest.skipIf(DATA_ROOT is None, @unittest.skipIf(OPJ_DATA_ROOT is None,
"OPJ_DATA_ROOT environment variable not set") "OPJ_DATA_ROOT environment variable not set")
def test_differing_subsamples(self): def test_differing_subsamples(self):
"""verify printing of SIZ with different subsampling... Issue 86.""" """verify printing of SIZ with different subsampling... Issue 86."""
filename = os.path.join(DATA_ROOT, 'input/conformance/p0_05.j2k') filename = opj_data_file('input/conformance/p0_05.j2k')
j = glymur.Jp2k(filename) j = glymur.Jp2k(filename)
codestream = j.get_codestream() codestream = j.get_codestream()
with patch('sys.stdout', new=StringIO()) as fake_out: with patch('sys.stdout', new=StringIO()) as fake_out:
@ -828,11 +822,11 @@ class TestPrinting(unittest.TestCase):
expected = '\n'.join(lines) expected = '\n'.join(lines)
self.assertEqual(actual, expected) self.assertEqual(actual, expected)
@unittest.skipIf(DATA_ROOT is None, @unittest.skipIf(OPJ_DATA_ROOT is None,
"OPJ_DATA_ROOT environment variable not set") "OPJ_DATA_ROOT environment variable not set")
def test_palette_box(self): def test_palette_box(self):
"""Verify that palette (pclr) boxes are printed without error.""" """Verify that palette (pclr) boxes are printed without error."""
filename = os.path.join(DATA_ROOT, 'input/conformance/file9.jp2') filename = opj_data_file('input/conformance/file9.jp2')
j = glymur.Jp2k(filename) j = glymur.Jp2k(filename)
with patch('sys.stdout', new=StringIO()) as fake_out: with patch('sys.stdout', new=StringIO()) as fake_out:
print(j.box[2].box[1]) print(j.box[2].box[1])
@ -921,13 +915,13 @@ class TestPrinting(unittest.TestCase):
@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")
@unittest.skipIf(DATA_ROOT is None, @unittest.skipIf(OPJ_DATA_ROOT is None,
"OPJ_DATA_ROOT environment variable not set") "OPJ_DATA_ROOT environment variable not set")
def test_jpx_approx_icc_profile(self): def test_jpx_approx_icc_profile(self):
"""verify jpx with approx field equal to zero""" """verify jpx with approx field equal to zero"""
# ICC profiles may be used in JP2, but the approximation field should # ICC profiles may be used in JP2, but the approximation field should
# be zero unless we have jpx. This file does both. # be zero unless we have jpx. This file does both.
filename = os.path.join(DATA_ROOT, 'input/nonregression/text_GBR.jp2') filename = opj_data_file('input/nonregression/text_GBR.jp2')
with warnings.catch_warnings(): with warnings.catch_warnings():
# brand is 'jp2 ', but has any icc profile. # brand is 'jp2 ', but has any icc profile.
warnings.simplefilter("ignore") warnings.simplefilter("ignore")
@ -966,11 +960,11 @@ class TestPrinting(unittest.TestCase):
expected = '\n'.join(lines) expected = '\n'.join(lines)
self.assertEqual(actual, expected) self.assertEqual(actual, expected)
@unittest.skipIf(DATA_ROOT is None, @unittest.skipIf(OPJ_DATA_ROOT is None,
"OPJ_DATA_ROOT environment variable not set") "OPJ_DATA_ROOT environment variable not set")
def test_uuid(self): def test_uuid(self):
"""verify printing of UUID box""" """verify printing of UUID box"""
filename = os.path.join(DATA_ROOT, 'input/nonregression/text_GBR.jp2') filename = opj_data_file('input/nonregression/text_GBR.jp2')
with warnings.catch_warnings(): with warnings.catch_warnings():
# brand is 'jp2 ', but has any icc profile. # brand is 'jp2 ', but has any icc profile.
warnings.simplefilter("ignore") warnings.simplefilter("ignore")

View file

@ -2,7 +2,7 @@ from setuptools import setup, find_packages
import sys import sys
kwargs = {'name': 'Glymur', kwargs = {'name': 'Glymur',
'version': '0.4.0', 'version': '0.4.1',
'description': 'Tools for accessing JPEG2000 files', 'description': 'Tools for accessing JPEG2000 files',
'long_description': open('README.md').read(), 'long_description': open('README.md').read(),
'author': 'John Evans', 'author': 'John Evans',