[Git][debian-gis-team/glymur][upstream] New upstream version 0.13.4

Antonio Valentino (@antonio.valentino) gitlab at salsa.debian.org
Sat Jul 6 08:38:49 BST 2024



Antonio Valentino pushed to branch upstream at Debian GIS Project / glymur


Commits:
956e19c1 by Antonio Valentino at 2024-07-06T07:16:06+00:00
New upstream version 0.13.4
- - - - -


18 changed files:

- CHANGES.txt
- ci/travis-310.yaml
- ci/travis-311-no-gdal.yaml
- ci/travis-311.yaml
- ci/travis-312.yaml
- ci/travis-39.yaml
- docs/source/conf.py
- docs/source/whatsnew/0.13.rst
- glymur/codestream.py
- glymur/jp2box.py
- glymur/jp2k.py
- glymur/version.py
- setup.cfg
- + tests/data/jph_siz.txt
- + tests/data/oj-ht-byte.jph
- tests/test_jp2box.py
- tests/test_jp2k.py
- tests/test_printing.py


Changes:

=====================================
CHANGES.txt
=====================================
@@ -1,3 +1,7 @@
+July 4, 2024 - v0.13.4
+    Don't reset openjpeg codec in Jp2k if already set in Jp2kr.
+    Update CI configuration to specify openjpeg versions.
+    
 June 30, 2024 - v0.13.3
     Refactor parsing errors and warnings.
     Update CI configuration for numpy 2.0.


=====================================
ci/travis-310.yaml
=====================================
@@ -7,6 +7,6 @@ dependencies:
     - libtiff
     - lxml
     - numpy>=1.25,<1.26
-    - openjpeg
+    - openjpeg>=2.4,<2.5
     - pytest-xdist
     - scikit-image


=====================================
ci/travis-311-no-gdal.yaml
=====================================
@@ -6,6 +6,6 @@ dependencies:
     - libtiff
     - lxml
     - numpy>=1.26,<2.0
-    - openjpeg
+    - openjpeg>=2.5
     - pytest-xdist
     - scikit-image


=====================================
ci/travis-311.yaml
=====================================
@@ -7,6 +7,6 @@ dependencies:
     - libtiff
     - lxml
     - numpy>=1.26,<2.0
-    - openjpeg
+    - openjpeg>=2.5
     - pytest-xdist
     - scikit-image


=====================================
ci/travis-312.yaml
=====================================
@@ -7,6 +7,6 @@ dependencies:
     - libtiff
     - lxml
     - numpy>=2.0
-    - openjpeg
+    - openjpeg>=2.5
     - pytest-xdist
     - scikit-image


=====================================
ci/travis-39.yaml
=====================================
@@ -6,7 +6,7 @@ dependencies:
     - gdal
     - lxml
     - numpy>=1.24,<1.25
-    - openjpeg
+    - openjpeg>=2.4,<2.5
     - scikit-image
     - libtiff
     - pytest-xdist


=====================================
docs/source/conf.py
=====================================
@@ -78,7 +78,7 @@ copyright = '2013-2024, John Evans'
 # The short X.Y version.
 version = '0.13'
 # The full version, including alpha/beta/rc tags.
-release = '0.13.3'
+release = '0.13.4'
 
 # The language for content autogenerated by Sphinx. Refer to documentation
 # for a list of supported languages.


=====================================
docs/source/whatsnew/0.13.rst
=====================================
@@ -2,6 +2,13 @@
 Changes in glymur 0.13
 ######################
 
+*****************
+Changes in 0.13.4
+*****************
+
+    * Don't reset openjpeg codec in Jp2k if already set in Jp2kr.
+    * Update CI configuration to specify openjpeg versions.
+
 *****************
 Changes in 0.13.3
 *****************


=====================================
glymur/codestream.py
=====================================
@@ -736,7 +736,9 @@ class Codestream(object):
         data = struct.unpack_from('>HIIIIIIIIH', read_buffer)
 
         rsiz = data[0]
-        if rsiz not in _KNOWN_PROFILES:
+
+        # Bit 14 (16384) signifies HTJ2K (JPH)
+        if rsiz not in _KNOWN_PROFILES and not np.bitwise_and(rsiz, 16384):
             msg = f"Invalid profile: (Rsiz={rsiz})."
             warnings.warn(msg, UserWarning)
 
@@ -1666,7 +1668,12 @@ class SIZsegment(Segment):
         try:
             profile = _CAPABILITIES_DISPLAY[self.rsiz]
         except KeyError:
-            profile = f'{self.rsiz} (invalid)'
+            if np.bitwise_and(self.rsiz, 16384):
+                # HTJ2K profile that is uninterpreted
+                profile = f'{self.rsiz}'
+            else:
+                # profile unknown
+                profile = f'{self.rsiz} (invalid)'
         msg = msg.format(
             profile=profile,
             height=self.ysiz, width=self.xsiz,


=====================================
glymur/jp2box.py
=====================================
@@ -1259,7 +1259,7 @@ class FileTypeBox(Jp2kBox):
     """
     box_id = 'ftyp'
     longname = 'File Type'
-    _valid_cls = ['jp2 ', 'jpx ', 'jpxb']
+    _valid_cls = ['jp2 ', 'jph ', 'jpx ', 'jpxb']
 
     def __init__(
         self, brand='jp2 ', minor_version=0, compatibility_list=None,
@@ -1304,16 +1304,19 @@ class FileTypeBox(Jp2kBox):
         return text
 
     def _validate(self, writing=False):
-        """Validate the box before writing to file."""
-        if self.brand not in ['jp2 ', 'jpx ']:
+        """
+        Validate the box before writing to file.
+        """
+        if self.brand not in ['jp2 ', 'jpx ', 'jph ']:
             msg = (
                 f"The file type brand was '{self.brand}'.  "
-                f"It should be either 'jp2 ' or 'jpx '."
+                f"It should be either 'jp2 ', 'jpx ', or 'jph '."
             )
             if writing:
                 raise InvalidJp2kError(msg)
             else:
                 warnings.warn(msg, UserWarning)
+
         for item in self.compatibility_list:
             if item not in self._valid_cls:
                 msg = (


=====================================
glymur/jp2k.py
=====================================
@@ -206,13 +206,13 @@ class Jp2k(Jp2kr):
             # Must be determined when writing.
             self._shape = None
 
-        # If there already was a shape attribute, then don't mess with it,
-        # it was set by the reader superclass.
-
-        if self.filename[-4:].endswith(('.jp2', '.JP2', '.jpx', 'JPX')):
-            self._codec_format = opj2.CODEC_JP2
-        else:
-            self._codec_format = opj2.CODEC_J2K
+        if not hasattr(self, '_codec_format'):
+            # Only set codec format if the superclass has not done so, i.e.
+            # we are writing instead of reading.
+            if self.filename[-4:].endswith(('.jp2', '.JP2', '.jpx', 'JPX')):
+                self._codec_format = opj2.CODEC_JP2
+            else:
+                self._codec_format = opj2.CODEC_J2K
 
         self._validate_kwargs()
 


=====================================
glymur/version.py
=====================================
@@ -20,7 +20,7 @@ from .lib import tiff
 
 # Do not change the format of this next line!  Doing so risks breaking
 # setup.py
-version = "0.13.3"
+version = "0.13.4"
 
 version_tuple = parse(version).release
 


=====================================
setup.cfg
=====================================
@@ -1,6 +1,6 @@
 [metadata]
 name = Glymur
-version = 0.13.3
+version = 0.13.4
 author = 'John Evans'
 author_email = "John Evans" <jevans667cc at proton.me>
 license = 'MIT'


=====================================
tests/data/jph_siz.txt
=====================================
@@ -0,0 +1,9 @@
+SIZ marker segment @ (424, 41)
+    Profile:  16384
+    Reference Grid Height, Width:  (20 x 20)
+    Vertical, Horizontal Reference Grid Offset:  (0 x 0)
+    Reference Tile Height, Width:  (20 x 20)
+    Vertical, Horizontal Reference Tile Offset:  (0 x 0)
+    Bitdepth:  (8,)
+    Signed:  (False,)
+    Vertical, Horizontal Subsampling:  ((1, 1),)


=====================================
tests/data/oj-ht-byte.jph
=====================================
Binary files /dev/null and b/tests/data/oj-ht-byte.jph differ


=====================================
tests/test_jp2box.py
=====================================
@@ -20,7 +20,7 @@ import numpy as np
 
 # Local imports ...
 import glymur
-from glymur import Jp2k
+from glymur import Jp2k, Jp2kr
 from glymur.jp2box import (
     ColourSpecificationBox, ContiguousCodestreamBox, FileTypeBox,
     ImageHeaderBox, JP2HeaderBox, JPEG2000SignatureBox, BitsPerComponentBox,
@@ -356,6 +356,16 @@ class TestChannelDefinition(fixtures.TestCommon):
 class TestFileTypeBox(fixtures.TestCommon):
     """Test suite for ftyp box issues."""
 
+    def test_jph(self):
+        """
+        SCENARIO:  JPH box
+
+        EXPECTED RESULT:  The brand is verified.
+        """
+        path = ir.files('tests.data').joinpath('oj-ht-byte.jph')
+        j = Jp2kr(path)
+        self.assertEqual(j.box[1].brand, 'jph ')
+
     def test_bad_brand_on_parse(self):
         """
         SCENARIO:  The JP2 file file type box does not contain a valid brand.


=====================================
tests/test_jp2k.py
=====================================
@@ -38,6 +38,20 @@ class TestJp2k(fixtures.TestCommon):
         super().setUp()
         glymur.reset_option('all')
 
+    @unittest.skipIf(
+        glymur.version.openjpeg_version < '2.5.0', "Requires as least v2.5.0"
+    )
+    def test_read_htj2k(self):
+        """
+        Scenario:  read an HTJ2K (JPH) file using Jp2k
+
+        Expected response:  The size of the image read is verified.
+        """
+        path = ir.files('tests.data').joinpath('oj-ht-byte.jph')
+        j = Jp2k(path)
+        d = j[:]
+        self.assertEqual(d.shape, (20, 20))
+
     def test_repr(self):
         """
         Scenario:  run repr on Jp2k object


=====================================
tests/test_printing.py
=====================================
@@ -1607,6 +1607,27 @@ class TestPrinting(fixtures.TestCommon):
         )
         self.assertEqual(actual, expected)
 
+    def test_jph_rsiz(self):
+        """
+        Scenario:  parse a JPH file, print the SIZ segment
+
+        Expected result:  no warnings, the output is verified
+        """
+        path = ir.files('tests.data').joinpath('oj-ht-byte.jph')
+
+        with warnings.catch_warnings():
+            warnings.simplefilter('error')
+            j = Jp2k(path)
+            actual = str(j.codestream.segment[1])
+
+        expected = (
+            ir.files('tests.data')
+              .joinpath('jph_siz.txt')
+              .read_text()
+              .rstrip()
+        )
+        self.assertEqual(actual, expected)
+
 
 class TestJp2dump(fixtures.TestCommon):
     """Tests for verifying how jp2dump console script works."""



View it on GitLab: https://salsa.debian.org/debian-gis-team/glymur/-/commit/956e19c175d90f5d55ef1429447235f289ff02fb

-- 
This project does not include diff previews in email notifications.
View it on GitLab: https://salsa.debian.org/debian-gis-team/glymur/-/commit/956e19c175d90f5d55ef1429447235f289ff02fb
You're receiving this email because of your account on salsa.debian.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/pkg-grass-devel/attachments/20240706/793cfc49/attachment-0001.htm>


More information about the Pkg-grass-devel mailing list