[med-svn] [Git][python-team/packages/tifffile][upstream] New upstream version 20210108

Ole Streicher gitlab at salsa.debian.org
Sat Jan 9 13:35:14 GMT 2021



Ole Streicher pushed to branch upstream at Debian Python Team / packages / tifffile


Commits:
4951d3dc by Ole Streicher at 2021-01-09T14:31:54+01:00
New upstream version 20210108
- - - - -


11 changed files:

- CHANGES.rst
- LICENSE
- PKG-INFO
- README.rst
- setup.py
- tests/test_tifffile.py
- tifffile.egg-info/PKG-INFO
- tifffile.egg-info/requires.txt
- tifffile/tiffcomment.py
- tifffile/tifffile.py
- tifffile/tifffile_geodb.py


Changes:

=====================================
CHANGES.rst
=====================================
@@ -1,7 +1,10 @@
 Revisions
 ---------
-2020.12.8
+2021.1.8
     Pass 4376 tests.
+    Decode float24 using imagecodecs >= 2021.1.8.
+    Consolidate reading of segments if possible.
+2020.12.8
     Fix corrupted ImageDescription in multi shaped series if buffer too small.
     Fix libtiff warning that ImageDescription contains null byte in value.
     Fix reading invalid files using JPEG compression with palette colorspace.


=====================================
LICENSE
=====================================
@@ -1,6 +1,6 @@
 BSD 3-Clause License
 
-Copyright (c) 2008-2020, Christoph Gohlke
+Copyright (c) 2008-2021, Christoph Gohlke
 All rights reserved.
 
 Redistribution and use in source and binary forms, with or without


=====================================
PKG-INFO
=====================================
@@ -1,6 +1,6 @@
 Metadata-Version: 2.1
 Name: tifffile
-Version: 2020.12.8
+Version: 2021.1.8
 Summary: Read and write TIFF(r) files
 Home-page: https://www.lfd.uci.edu/~gohlke/
 Author: Christoph Gohlke
@@ -51,16 +51,16 @@ Description: Read and write TIFF(r) files
         
         :License: BSD 3-Clause
         
-        :Version: 2020.12.8
+        :Version: 2021.1.8
         
         Requirements
         ------------
         This release has been tested with the following requirements and dependencies
         (other versions may work):
         
-        * `CPython 3.7.9, 3.8.6, 3.9.1 64-bit <https://www.python.org>`_
-        * `Numpy 1.19.4 <https://pypi.org/project/numpy/>`_
-        * `Imagecodecs 2020.5.30 <https://pypi.org/project/imagecodecs/>`_
+        * `CPython 3.7.9, 3.8.7, 3.9.1 64-bit <https://www.python.org>`_
+        * `Numpy 1.19.5 <https://pypi.org/project/numpy/>`_
+        * `Imagecodecs 2021.1.8 <https://pypi.org/project/imagecodecs/>`_
           (required only for encoding or decoding LZW, JPEG, etc.)
         * `Matplotlib 3.3.3 <https://pypi.org/project/matplotlib/>`_
           (required only for plotting)
@@ -71,8 +71,11 @@ Description: Read and write TIFF(r) files
         
         Revisions
         ---------
-        2020.12.8
+        2021.1.8
             Pass 4376 tests.
+            Decode float24 using imagecodecs >= 2021.1.8.
+            Consolidate reading of segments if possible.
+        2020.12.8
             Fix corrupted ImageDescription in multi shaped series if buffer too small.
             Fix libtiff warning that ImageDescription contains null byte in value.
             Fix reading invalid files using JPEG compression with palette colorspace.
@@ -427,6 +430,11 @@ Description: Read and write TIFF(r) files
         ...         for tag in page.tags:
         ...             tag_name, tag_value = tag.name, tag.value
         
+        Overwrite the value of an existing tag, e.g. XResolution:
+        
+        >>> with TiffFile('temp.tif', mode='r+b') as tif:
+        ...     _ = tif.pages[0].tags['XResolution'].overwrite(tif, (96000, 1000))
+        
         Write a floating-point ndarray and metadata using BigTIFF format, tiling,
         compression, and planar storage:
         


=====================================
README.rst
=====================================
@@ -41,16 +41,16 @@ For command line usage run ``python -m tifffile --help``
 
 :License: BSD 3-Clause
 
-:Version: 2020.12.8
+:Version: 2021.1.8
 
 Requirements
 ------------
 This release has been tested with the following requirements and dependencies
 (other versions may work):
 
-* `CPython 3.7.9, 3.8.6, 3.9.1 64-bit <https://www.python.org>`_
-* `Numpy 1.19.4 <https://pypi.org/project/numpy/>`_
-* `Imagecodecs 2020.5.30 <https://pypi.org/project/imagecodecs/>`_
+* `CPython 3.7.9, 3.8.7, 3.9.1 64-bit <https://www.python.org>`_
+* `Numpy 1.19.5 <https://pypi.org/project/numpy/>`_
+* `Imagecodecs 2021.1.8 <https://pypi.org/project/imagecodecs/>`_
   (required only for encoding or decoding LZW, JPEG, etc.)
 * `Matplotlib 3.3.3 <https://pypi.org/project/matplotlib/>`_
   (required only for plotting)
@@ -61,8 +61,11 @@ This release has been tested with the following requirements and dependencies
 
 Revisions
 ---------
-2020.12.8
+2021.1.8
     Pass 4376 tests.
+    Decode float24 using imagecodecs >= 2021.1.8.
+    Consolidate reading of segments if possible.
+2020.12.8
     Fix corrupted ImageDescription in multi shaped series if buffer too small.
     Fix libtiff warning that ImageDescription contains null byte in value.
     Fix reading invalid files using JPEG compression with palette colorspace.
@@ -417,6 +420,11 @@ Iterate over all tags in the TIFF file:
 ...         for tag in page.tags:
 ...             tag_name, tag_value = tag.name, tag.value
 
+Overwrite the value of an existing tag, e.g. XResolution:
+
+>>> with TiffFile('temp.tif', mode='r+b') as tif:
+...     _ = tif.pages[0].tags['XResolution'].overwrite(tif, (96000, 1000))
+
 Write a floating-point ndarray and metadata using BigTIFF format, tiling,
 compression, and planar storage:
 


=====================================
setup.py
=====================================
@@ -82,11 +82,11 @@ setup(
     python_requires='>=3.7',
     install_requires=[
         'numpy>=1.15.1',
-        # 'imagecodecs>=2020.5.30',
+        # 'imagecodecs>=2021.1.8',
     ],
     extras_require={
         'all': [
-            'imagecodecs>=2020.5.30',
+            'imagecodecs>=2021.1.8',
             'matplotlib>=3.2',
             'lxml',
             # 'zarr>=2.5.0'


=====================================
tests/test_tifffile.py
=====================================
@@ -1,6 +1,6 @@
 # test_tifffile.py
 
-# Copyright (c) 2008-2020, Christoph Gohlke
+# Copyright (c) 2008-2021, Christoph Gohlke
 # All rights reserved.
 #
 # Redistribution and use in source and binary forms, with or without
@@ -42,7 +42,7 @@ Private data files are not available due to size and copyright restrictions.
 
 :License: BSD 3-Clause
 
-:Version: 2020.12.8
+:Version: 2021.1.8
 
 """
 
@@ -396,7 +396,7 @@ def test_issue_deprecated_import():
 def test_issue_imread_kwargs():
     """Test that is_flags are handled by imread."""
     data = random_data('uint16', (5, 63, 95))
-    with TempFileName(f'issue_imread_kwargs') as fname:
+    with TempFileName('issue_imread_kwargs') as fname:
         with TiffWriter(fname) as tif:
             for image in data:
                 tif.write(image)  # create 5 series
@@ -1306,13 +1306,13 @@ def test_class_tifftags():
 def test_class_tifftagregistry():
     """Test TiffTagRegistry."""
     tags = TIFF.TAGS
-    assert len(tags) == 620
+    assert len(tags) == 624
     assert tags[11] == 'ProcessingSoftware'
     assert tags['ProcessingSoftware'] == 11
     assert tags.getall(11) == ['ProcessingSoftware']
     assert tags.getall('ProcessingSoftware') == [11]
     tags.add(11, 'ProcessingSoftware')
-    assert len(tags) == 620
+    assert len(tags) == 624
 
     # one code with two names
     assert 34853 in tags
@@ -1325,7 +1325,7 @@ def test_class_tifftagregistry():
     assert tags.getall('GPSTag') == [34853]
 
     del tags[34853]
-    assert len(tags) == 618
+    assert len(tags) == 622
     assert 34853 not in tags
     assert 'GPSTag' not in tags
     assert 'OlympusSIS2' not in tags
@@ -1351,7 +1351,7 @@ def test_class_tifftagregistry():
     assert tags.getall(41483) == ['FlashEnergy']
 
     del tags['FlashEnergy']
-    assert len(tags) == 618
+    assert len(tags) == 622
     assert 37387 not in tags
     assert 41483 not in tags
     assert 'FlashEnergy' not in tags
@@ -2947,10 +2947,10 @@ def test_read_tigers(fname):
             assert page.photometric == MINISBLACK
 
         # float24 not supported
-        if 'float' in fname and databits == 24:
-            with pytest.raises(ValueError):
-                data = tif.asarray()
-            return
+        # if 'float' in fname and databits == 24:
+        #     with pytest.raises(ValueError):
+        #         data = tif.asarray()
+        #     return
 
         # assert data shapes
         data = tif.asarray()
@@ -2974,7 +2974,10 @@ def test_read_tigers(fname):
 
         # assert data types
         if 'float' in fname:
-            dtype = f'float{databits}'
+            if databits == 24:
+                dtype = 'float32'
+            else:
+                dtype = f'float{databits}'
         # elif 'palette' in fname:
         #     dtype = 'uint16'
         elif databits == 1:


=====================================
tifffile.egg-info/PKG-INFO
=====================================
@@ -1,6 +1,6 @@
 Metadata-Version: 2.1
 Name: tifffile
-Version: 2020.12.8
+Version: 2021.1.8
 Summary: Read and write TIFF(r) files
 Home-page: https://www.lfd.uci.edu/~gohlke/
 Author: Christoph Gohlke
@@ -51,16 +51,16 @@ Description: Read and write TIFF(r) files
         
         :License: BSD 3-Clause
         
-        :Version: 2020.12.8
+        :Version: 2021.1.8
         
         Requirements
         ------------
         This release has been tested with the following requirements and dependencies
         (other versions may work):
         
-        * `CPython 3.7.9, 3.8.6, 3.9.1 64-bit <https://www.python.org>`_
-        * `Numpy 1.19.4 <https://pypi.org/project/numpy/>`_
-        * `Imagecodecs 2020.5.30 <https://pypi.org/project/imagecodecs/>`_
+        * `CPython 3.7.9, 3.8.7, 3.9.1 64-bit <https://www.python.org>`_
+        * `Numpy 1.19.5 <https://pypi.org/project/numpy/>`_
+        * `Imagecodecs 2021.1.8 <https://pypi.org/project/imagecodecs/>`_
           (required only for encoding or decoding LZW, JPEG, etc.)
         * `Matplotlib 3.3.3 <https://pypi.org/project/matplotlib/>`_
           (required only for plotting)
@@ -71,8 +71,11 @@ Description: Read and write TIFF(r) files
         
         Revisions
         ---------
-        2020.12.8
+        2021.1.8
             Pass 4376 tests.
+            Decode float24 using imagecodecs >= 2021.1.8.
+            Consolidate reading of segments if possible.
+        2020.12.8
             Fix corrupted ImageDescription in multi shaped series if buffer too small.
             Fix libtiff warning that ImageDescription contains null byte in value.
             Fix reading invalid files using JPEG compression with palette colorspace.
@@ -427,6 +430,11 @@ Description: Read and write TIFF(r) files
         ...         for tag in page.tags:
         ...             tag_name, tag_value = tag.name, tag.value
         
+        Overwrite the value of an existing tag, e.g. XResolution:
+        
+        >>> with TiffFile('temp.tif', mode='r+b') as tif:
+        ...     _ = tif.pages[0].tags['XResolution'].overwrite(tif, (96000, 1000))
+        
         Write a floating-point ndarray and metadata using BigTIFF format, tiling,
         compression, and planar storage:
         


=====================================
tifffile.egg-info/requires.txt
=====================================
@@ -1,6 +1,6 @@
 numpy>=1.15.1
 
 [all]
-imagecodecs>=2020.5.30
+imagecodecs>=2021.1.8
 matplotlib>=3.2
 lxml


=====================================
tifffile/tiffcomment.py
=====================================
@@ -45,7 +45,7 @@ def main(argv=None):
         try:
             comment = comment.encode('ascii')
         except UnicodeEncodeError as exc:
-            print(f'{file}: {exc}')
+            print(f'{exc}')
             comment = comment.encode()
 
     for file in files:


=====================================
tifffile/tifffile.py
=====================================
@@ -1,6 +1,6 @@
 # tifffile.py
 
-# Copyright (c) 2008-2020, Christoph Gohlke
+# Copyright (c) 2008-2021, Christoph Gohlke
 # All rights reserved.
 #
 # Redistribution and use in source and binary forms, with or without
@@ -71,16 +71,16 @@ For command line usage run ``python -m tifffile --help``
 
 :License: BSD 3-Clause
 
-:Version: 2020.12.8
+:Version: 2021.1.8
 
 Requirements
 ------------
 This release has been tested with the following requirements and dependencies
 (other versions may work):
 
-* `CPython 3.7.9, 3.8.6, 3.9.1 64-bit <https://www.python.org>`_
-* `Numpy 1.19.4 <https://pypi.org/project/numpy/>`_
-* `Imagecodecs 2020.5.30 <https://pypi.org/project/imagecodecs/>`_
+* `CPython 3.7.9, 3.8.7, 3.9.1 64-bit <https://www.python.org>`_
+* `Numpy 1.19.5 <https://pypi.org/project/numpy/>`_
+* `Imagecodecs 2021.1.8 <https://pypi.org/project/imagecodecs/>`_
   (required only for encoding or decoding LZW, JPEG, etc.)
 * `Matplotlib 3.3.3 <https://pypi.org/project/matplotlib/>`_
   (required only for plotting)
@@ -91,8 +91,11 @@ This release has been tested with the following requirements and dependencies
 
 Revisions
 ---------
-2020.12.8
+2021.1.8
     Pass 4376 tests.
+    Decode float24 using imagecodecs >= 2021.1.8.
+    Consolidate reading of segments if possible.
+2020.12.8
     Fix corrupted ImageDescription in multi shaped series if buffer too small.
     Fix libtiff warning that ImageDescription contains null byte in value.
     Fix reading invalid files using JPEG compression with palette colorspace.
@@ -447,6 +450,11 @@ Iterate over all tags in the TIFF file:
 ...         for tag in page.tags:
 ...             tag_name, tag_value = tag.name, tag.value
 
+Overwrite the value of an existing tag, e.g. XResolution:
+
+>>> with TiffFile('temp.tif', mode='r+b') as tif:
+...     _ = tif.pages[0].tags['XResolution'].overwrite(tif, (96000, 1000))
+
 Write a floating-point ndarray and metadata using BigTIFF format, tiling,
 compression, and planar storage:
 
@@ -606,7 +614,7 @@ as numpy or zarr arrays:
 
 """
 
-__version__ = '2020.12.8'
+__version__ = '2021.1.8'
 
 __all__ = (
     'imwrite',
@@ -5915,6 +5923,12 @@ class TiffPage:
                 # return numpy array from packed integers
                 return unpack_rgb(data, dtype, self.bitspersample)
 
+        elif self.bitspersample == 24 and dtype.char == 'f':
+            # float24
+            def unpack(data, byteorder=self.parent.byteorder):
+                # return numpy.float32 array from float24
+                return float24_decode(data, byteorder)
+
         else:
             # bilevel and packed integers
             def unpack(data):
@@ -8813,6 +8827,7 @@ class FileHandle:
             Iterator over individual or lists of (segment, index) tuples.
 
         """
+        # TODO: Cythonize this?
         length = len(offsets)
         if length < 1:
             return
@@ -8832,7 +8847,7 @@ class FileHandle:
         if lock is None:
             lock = self._lock
         if buffersize is None:
-            buffersize = 2 ** 26  # 64 MB
+            buffersize = 67108864  # 2 ** 26, 64 MB
 
         if indices is None:
             segments = [(i, offsets[i], bytecounts[i]) for i in range(length)]
@@ -8843,15 +8858,64 @@ class FileHandle:
         if sort:
             segments = sorted(segments, key=lambda x: x[1])
 
+        iscontig = True
+        for i in range(length - 1):
+            _, offset, bytecount = segments[i]
+            nextoffset = segments[i + 1][1]
+            if offset == 0 or bytecount == 0 or nextoffset == 0:
+                continue
+            if offset + bytecount != nextoffset:
+                iscontig = False
+                break
+
         seek = self.seek
         read = self._fh.read
+
+        if iscontig:
+            # consolidate reads
+            i = 0
+            while i < length:
+                j = i
+                offset = None
+                bytecount = 0
+                while bytecount < buffersize and i < length:
+                    _, o, b = segments[i]
+                    if o > 0 and b > 0:
+                        if offset is None:
+                            offset = o
+                        bytecount += b
+                    i += 1
+
+                if offset is None:
+                    data = None
+                else:
+                    with lock:
+                        seek(offset)
+                        data = read(bytecount)
+                start = 0
+                stop = 0
+                result = []
+                while j < i:
+                    index, offset, bytecount = segments[j]
+                    if offset > 0 and bytecount > 0:
+                        stop += bytecount
+                        result.append((data[start:stop], index))
+                        start = stop
+                    else:
+                        result.append((None, index))
+                    j += 1
+                if flat:
+                    yield from result
+                else:
+                    yield result
+            return
+
         i = 0
         while i < length:
             result = []
             size = 0
             with lock:
                 while size < buffersize and i < length:
-                    # TODO: consolidate reads?
                     index, offset, bytecount = segments[i]
                     if offset > 0 and bytecount > 0:
                         seek(offset)
@@ -10158,7 +10222,8 @@ class TIFF:
                 (34853, 'GPSTag'),  # GPSIFD  also OlympusSIS2
                 (34853, 'OlympusSIS2'),
                 (34855, 'ISOSpeedRatings'),
-                (34856, 'OECF'),
+                (34855, 'PhotographicSensitivity'),
+                (34856, 'OECF'),  # optoelectric conversion factor
                 (34857, 'Interlace'),
                 (34858, 'TimeZoneOffset'),
                 (34859, 'SelfTimerMode'),
@@ -10311,6 +10376,9 @@ class TIFF:
                 (42035, 'LensMake'),
                 (42036, 'LensModel'),
                 (42037, 'LensSerialNumber'),
+                (42080, 'CompositeImage'),
+                (42081, 'SourceImageNumberCompositeImage'),
+                (42082, 'SourceExposureTimesCompositeImage'),
                 (42112, 'GDAL_METADATA'),
                 (42113, 'GDAL_NODATA'),
                 (42240, 'Gamma'),
@@ -10420,7 +10488,7 @@ class TIFF:
                 (50909, 'GEO_METADATA'),  # DGIWG XML
                 (50931, 'CameraCalibrationSignature'),
                 (50932, 'ProfileCalibrationSignature'),
-                (50933, 'ProfileIFD'),
+                (50933, 'ProfileIFD'),  # EXTRACAMERAPROFILES
                 (50934, 'AsShotProfileName'),
                 (50935, 'NoiseReductionApplied'),
                 (50936, 'ProfileName'),
@@ -10953,7 +11021,7 @@ class TIFF:
             (2, 64): 'q',
             # IEEEFP
             (3, 16): 'e',
-            # (3, 24): '',  # 24 bit not supported by numpy
+            (3, 24): 'f',  # float24 bit not supported by numpy
             (3, 32): 'f',
             (3, 64): 'd',
             # COMPLEXIEEEFP
@@ -13790,6 +13858,11 @@ def unpack_rgb(data, dtype=None, bitspersample=None, rescale=True):
     return result.reshape(-1)
 
 
+def float24_decode(data, byteorder):
+    """Return float32 array from float24."""
+    raise NotImplementedError('float24_decode')
+
+
 if imagecodecs is None:
     import lzma
     import zlib
@@ -13971,6 +14044,10 @@ else:
     bitorder_decode = imagecodecs.bitorder_decode  # noqa
     packints_decode = imagecodecs.packints_decode  # noqa
     packints_encode = imagecodecs.packints_encode  # noqa
+    try:
+        float24_decode = imagecodecs.float24_decode  # noqa
+    except AttributeError:
+        pass
 
 
 def apply_colormap(image, colormap, contig=True):


=====================================
tifffile/tifffile_geodb.py
=====================================
@@ -2005,24 +2005,6 @@ class VertCS(enum.IntEnum):
     Caspian_Sea = 5106
 
 
-GEO_CODES = {
-    'GTModelTypeGeoKey': ModelType,
-    'GTRasterTypeGeoKey': RasterPixel,
-    'GeographicTypeGeoKey': GCS,
-    'GeogEllipsoidGeoKey': Ellipse,
-    'ProjectedCSTypeGeoKey': PCS,
-    'ProjectionGeoKey': Proj,
-    'VerticalCSTypeGeoKey': VertCS,
-    # 'VerticalDatumGeoKey': VertCS,
-    'GeogLinearUnitsGeoKey': Linear,
-    'ProjLinearUnitsGeoKey': Linear,
-    'VerticalUnitsGeoKey': Linear,
-    'GeogAngularUnitsGeoKey': Angular,
-    'GeogAzimuthUnitsGeoKey': Angular,
-    'ProjCoordTransGeoKey': CT,
-    'GeogPrimeMeridianGeoKey': PM,
-}
-
 GEO_KEYS = {
     1024: 'GTModelTypeGeoKey',
     1025: 'GTRasterTypeGeoKey',
@@ -2073,3 +2055,21 @@ GEO_KEYS = {
     4098: 'VerticalDatumGeoKey',
     4099: 'VerticalUnitsGeoKey',
 }
+
+GEO_CODES = {
+    GEO_KEYS[1024]: ModelType,  # GTModelTypeGeoKey
+    GEO_KEYS[1025]: RasterPixel,  # GTRasterTypeGeoKey
+    GEO_KEYS[2048]: GCS,  # GeographicTypeGeoKey
+    GEO_KEYS[2051]: PM,  # GeogPrimeMeridianGeoKey
+    GEO_KEYS[2052]: Linear,  # GeogLinearUnitsGeoKey
+    GEO_KEYS[2054]: Angular,  # GeogAngularUnitsGeoKey
+    GEO_KEYS[2056]: Ellipse,  # GeogEllipsoidGeoKey
+    GEO_KEYS[2060]: Angular,  # GeogAzimuthUnitsGeoKey
+    GEO_KEYS[3072]: PCS,  # ProjectedCSTypeGeoKey
+    GEO_KEYS[3074]: Proj,  # ProjectionGeoKey
+    GEO_KEYS[3075]: CT,  # ProjCoordTransGeoKey
+    GEO_KEYS[3076]: Linear,  # ProjLinearUnitsGeoKey
+    GEO_KEYS[4096]: VertCS,  # VerticalCSTypeGeoKey
+    # GEO_KEYS[4098]: VertCS,  # VerticalDatumGeoKey
+    GEO_KEYS[4099]: Linear,  # VerticalUnitsGeoKey
+}



View it on GitLab: https://salsa.debian.org/python-team/packages/tifffile/-/commit/4951d3dc86c8a9202f96295ec35dec3a82a25e2f

-- 
View it on GitLab: https://salsa.debian.org/python-team/packages/tifffile/-/commit/4951d3dc86c8a9202f96295ec35dec3a82a25e2f
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/debian-med-commit/attachments/20210109/d77e0c86/attachment-0001.html>


More information about the debian-med-commit mailing list