[med-svn] [Git][python-team/modules/tifffile][upstream] New upstream version 20200511
Ole Streicher
gitlab at salsa.debian.org
Fri May 15 19:32:04 BST 2020
Ole Streicher pushed to branch upstream at Debian Python Team / DPMT / tifffile
Commits:
cddd23a4 by Ole Streicher at 2020-05-15T20:16:00+02:00
New upstream version 20200511
- - - - -
19 changed files:
- + ACKNOWLEDGEMENTS.rst
- + CHANGES.rst
- LICENSE
- MANIFEST.in
- PKG-INFO
- README.rst
- setup.py
- − setup_tiffile.py
- tests/conftest.py
- tests/test_tifffile.py
- tifffile.egg-info/PKG-INFO
- tifffile.egg-info/SOURCES.txt
- tifffile.egg-info/requires.txt
- tifffile/__init__.py
- tifffile/__main__.py
- tifffile/lsm2bin.py
- tifffile/tifffile.py
- tifffile/tifffile_geodb.py
- − tiffile.py
Changes:
=====================================
ACKNOWLEDGEMENTS.rst
=====================================
@@ -0,0 +1,7 @@
+Acknowledgements
+----------------
+* Egor Zindy, for lsm_scan_info specifics.
+* Wim Lewis for a bug fix and some LSM functions.
+* Hadrien Mary for help on reading MicroManager files.
+* Christian Kliche for help writing tiled and color-mapped files.
+* Grzegorz Bokota, for reporting and fixing OME-XML handling issues.
=====================================
CHANGES.rst
=====================================
@@ -0,0 +1,380 @@
+Revisions
+---------
+2020.5.11
+ Pass 2908 tests.
+ Fix reading ImageJ grayscale mode RGB images (#6).
+ Remove napari reader plugin.
+2020.5.7
+ Add napari reader plugin (tentative).
+ Fix writing single tiles larger than image data (#3).
+ Always store ExtraSamples values in tuple (breaking).
+2020.5.5
+ Allow to write tiled TIFF from iterator of tiles (WIP).
+ Add function to iterate over decoded segments of TiffPage (WIP).
+ Pass chunks of segments to ThreadPoolExecutor.map to reduce memory usage.
+ Fix reading invalid files with too many strips.
+ Fix writing over-aligned image data.
+ Detect OME-XML without declaration (#2).
+ Support LERC compression (WIP).
+ Delay load imagecodecs functions.
+ Remove maxsize parameter from asarray (breaking).
+ Deprecate ijmetadata parameter from TiffWriter.save (use metadata).
+2020.2.16
+ Add function to decode individual strips or tiles.
+ Read strips and tiles in order of their offsets.
+ Enable multi-threading when decompressing multiple strips.
+ Replace TiffPage.tags dictionary with TiffTags (breaking).
+ Replace TIFF.TAGS dictionary with TiffTagRegistry.
+ Remove TIFF.TAG_NAMES (breaking).
+ Improve handling of TiffSequence parameters in imread.
+ Match last uncommon parts of file paths to FileSequence pattern (breaking).
+ Allow letters in FileSequence pattern for indexing well plate rows.
+ Allow to reorder axes in FileSequence.
+ Allow to write > 4 GB arrays to plain TIFF when using compression.
+ Allow to write zero size numpy arrays to nonconformant TIFF (tentative).
+ Fix xml2dict.
+ Require imagecodecs >= 2020.1.31.
+ Remove support for imagecodecs-lite (breaking).
+ Remove verify parameter to asarray function (breaking).
+ Remove deprecated lzw_decode functions (breaking).
+ Remove support for Python 2.7 and 3.5 (breaking).
+2019.7.26
+ Fix infinite loop reading more than two tags of same code in IFD.
+ Delay import of logging module.
+2019.7.20
+ Fix OME-XML detection for files created by Imaris.
+ Remove or replace assert statements.
+2019.7.2
+ Do not write SampleFormat tag for unsigned data types.
+ Write ByteCount tag values as SHORT or LONG if possible.
+ Allow to specify axes in FileSequence pattern via group names.
+ Add option to concurrently read FileSequence using threads.
+ Derive TiffSequence from FileSequence.
+ Use str(datetime.timedelta) to format Timer duration.
+ Use perf_counter for Timer if possible.
+2019.6.18
+ Fix reading planar RGB ImageJ files created by Bio-Formats.
+ Fix reading single-file, multi-image OME-TIFF without UUID.
+ Presume LSM stores uncompressed images contiguously per page.
+ Reformat some complex expressions.
+2019.5.30
+ Ignore invalid frames in OME-TIFF.
+ Set default subsampling to (2, 2) for RGB JPEG compression.
+ Fix reading and writing planar RGB JPEG compression.
+ Replace buffered_read with FileHandle.read_segments.
+ Include page or frame numbers in exceptions and warnings.
+ Add Timer class.
+2019.5.22
+ Add optional chroma subsampling for JPEG compression.
+ Enable writing PNG, JPEG, JPEGXR, and JPEG2K compression (WIP).
+ Fix writing tiled images with WebP compression.
+ Improve handling GeoTIFF sparse files.
+2019.3.18
+ Fix regression decoding JPEG with RGB photometrics.
+ Fix reading OME-TIFF files with corrupted but unused pages.
+ Allow to load TiffFrame without specifying keyframe.
+ Calculate virtual TiffFrames for non-BigTIFF ScanImage files > 2GB.
+ Rename property is_chroma_subsampled to is_subsampled (breaking).
+ Make more attributes and methods private (WIP).
+2019.3.8
+ Fix MemoryError when RowsPerStrip > ImageLength.
+ Fix SyntaxWarning on Python 3.8.
+ Fail to decode JPEG to planar RGB (tentative).
+ Separate public from private test files (WIP).
+ Allow testing without data files or imagecodecs.
+2019.2.22
+ Use imagecodecs-lite as a fallback for imagecodecs.
+ Simplify reading numpy arrays from file.
+ Use TiffFrames when reading arrays from page sequences.
+ Support slices and iterators in TiffPageSeries sequence interface.
+ Auto-detect uniform series.
+ Use page hash to determine generic series.
+ Turn off TiffPages cache (tentative).
+ Pass through more parameters in imread.
+ Discontinue movie parameter in imread and TiffFile (breaking).
+ Discontinue bigsize parameter in imwrite (breaking).
+ Raise TiffFileError in case of issues with TIFF structure.
+ Return TiffFile.ome_metadata as XML (breaking).
+ Ignore OME series when last dimensions are not stored in TIFF pages.
+2019.2.10
+ Assemble IFDs in memory to speed-up writing on some slow media.
+ Handle discontinued arguments fastij, multifile_close, and pages.
+2019.1.30
+ Use black background in imshow.
+ Do not write datetime tag by default (breaking).
+ Fix OME-TIFF with SamplesPerPixel > 1.
+ Allow 64-bit IFD offsets for NDPI (files > 4GB still not supported).
+2019.1.4
+ Fix decoding deflate without imagecodecs.
+2019.1.1
+ Update copyright year.
+ Require imagecodecs >= 2018.12.16.
+ Do not use JPEG tables from keyframe.
+ Enable decoding large JPEG in NDPI.
+ Decode some old-style JPEG.
+ Reorder OME channel axis to match PlanarConfiguration storage.
+ Return tiled images as contiguous arrays.
+ Add decode_lzw proxy function for compatibility with old czifile module.
+ Use dedicated logger.
+2018.11.28
+ Make SubIFDs accessible as TiffPage.pages.
+ Make parsing of TiffSequence axes pattern optional (breaking).
+ Limit parsing of TiffSequence axes pattern to file names, not path names.
+ Do not interpolate in imshow if image dimensions <= 512, else use bilinear.
+ Use logging.warning instead of warnings.warn in many cases.
+ Fix numpy FutureWarning for out == 'memmap'.
+ Adjust ZSTD and WebP compression to libtiff-4.0.10 (WIP).
+ Decode old-style LZW with imagecodecs >= 2018.11.8.
+ Remove TiffFile.qptiff_metadata (QPI metadata are per page).
+ Do not use keyword arguments before variable positional arguments.
+ Make either all or none return statements in a function return expression.
+ Use pytest parametrize to generate tests.
+ Replace test classes with functions.
+2018.11.6
+ Rename imsave function to imwrite.
+ Readd Python implementations of packints, delta, and bitorder codecs..
+ Fix TiffFrame.compression AttributeError.
+2018.10.18
+ Rename tiffile package to tifffile.
+2018.10.10
+ Read ZIF, the Zoomable Image Format (WIP).
+ Decode YCbCr JPEG as RGB (tentative).
+ Improve restoration of incomplete tiles.
+ Allow to write grayscale with extrasamples without specifying planarconfig.
+ Enable decoding of PNG and JXR via imagecodecs.
+ Deprecate 32-bit platforms (too many memory errors during tests).
+2018.9.27
+ Read Olympus SIS (WIP).
+ Allow to write non-BigTIFF files up to ~4 GB (fix).
+ Fix parsing date and time fields in SEM metadata.
+ Detect some circular IFD references.
+ Enable WebP codecs via imagecodecs.
+ Add option to read TiffSequence from ZIP containers.
+ Remove TiffFile.isnative.
+ Move TIFF struct format constants out of TiffFile namespace.
+2018.8.31
+ Fix wrong TiffTag.valueoffset.
+ Towards reading Hamamatsu NDPI (WIP).
+ Enable PackBits compression of byte and bool arrays.
+ Fix parsing NULL terminated CZ_SEM strings.
+2018.8.24
+ Move tifffile.py and related modules into tiffile package.
+ Move usage examples to module docstring.
+ Enable multi-threading for compressed tiles and pages by default.
+ Add option to concurrently decode image tiles using threads.
+ Do not skip empty tiles (fix).
+ Read JPEG and J2K compressed strips and tiles.
+ Allow floating-point predictor on write.
+ Add option to specify subfiletype on write.
+ Depend on imagecodecs package instead of _tifffile, lzma, etc modules.
+ Remove reverse_bitorder, unpack_ints, and decode functions.
+ Use pytest instead of unittest.
+2018.6.20
+ Save RGBA with unassociated extrasample by default (breaking).
+ Add option to specify ExtraSamples values.
+2018.6.17 (included with 0.15.1)
+ Towards reading JPEG and other compressions via imagecodecs package (WIP).
+ Read SampleFormat VOID as UINT.
+ Add function to validate TIFF using 'jhove -m TIFF-hul'.
+ Save bool arrays as bilevel TIFF.
+ Accept pathlib.Path as filenames.
+ Move 'software' argument from TiffWriter __init__ to save.
+ Raise DOS limit to 16 TB.
+ Lazy load LZMA and ZSTD compressors and decompressors.
+ Add option to save IJMetadata tags.
+ Return correct number of pages for truncated series (fix).
+ Move EXIF tags to TIFF.TAG as per TIFF/EP standard.
+2018.2.18
+ Always save RowsPerStrip and Resolution tags as required by TIFF standard.
+ Do not use badly typed ImageDescription.
+ Coerce bad ASCII string tags to bytes.
+ Tuning of __str__ functions.
+ Fix reading 'undefined' tag values.
+ Read and write ZSTD compressed data.
+ Use hexdump to print bytes.
+ Determine TIFF byte order from data dtype in imsave.
+ Add option to specify RowsPerStrip for compressed strips.
+ Allow memory-map of arrays with non-native byte order.
+ Attempt to handle ScanImage <= 5.1 files.
+ Restore TiffPageSeries.pages sequence interface.
+ Use numpy.frombuffer instead of fromstring to read from binary data.
+ Parse GeoTIFF metadata.
+ Add option to apply horizontal differencing before compression.
+ Towards reading PerkinElmer QPI (QPTIFF, no test files).
+ Do not index out of bounds data in tifffile.c unpackbits and decodelzw.
+2017.9.29
+ Many backward incompatible changes improving speed and resource usage:
+ Add detail argument to __str__ function. Remove info functions.
+ Fix potential issue correcting offsets of large LSM files with positions.
+ Remove TiffFile sequence interface; use TiffFile.pages instead.
+ Do not make tag values available as TiffPage attributes.
+ Use str (not bytes) type for tag and metadata strings (WIP).
+ Use documented standard tag and value names (WIP).
+ Use enums for some documented TIFF tag values.
+ Remove 'memmap' and 'tmpfile' options; use out='memmap' instead.
+ Add option to specify output in asarray functions.
+ Add option to concurrently decode pages using threads.
+ Add TiffPage.asrgb function (WIP).
+ Do not apply colormap in asarray.
+ Remove 'colormapped', 'rgbonly', and 'scale_mdgel' options from asarray.
+ Consolidate metadata in TiffFile _metadata functions.
+ Remove non-tag metadata properties from TiffPage.
+ Add function to convert LSM to tiled BIN files.
+ Align image data in file.
+ Make TiffPage.dtype a numpy.dtype.
+ Add 'ndim' and 'size' properties to TiffPage and TiffPageSeries.
+ Allow imsave to write non-BigTIFF files up to ~4 GB.
+ Only read one page for shaped series if possible.
+ Add memmap function to create memory-mapped array stored in TIFF file.
+ Add option to save empty arrays to TIFF files.
+ Add option to save truncated TIFF files.
+ Allow single tile images to be saved contiguously.
+ Add optional movie mode for files with uniform pages.
+ Lazy load pages.
+ Use lightweight TiffFrame for IFDs sharing properties with key TiffPage.
+ Move module constants to 'TIFF' namespace (speed up module import).
+ Remove 'fastij' option from TiffFile.
+ Remove 'pages' parameter from TiffFile.
+ Remove TIFFfile alias.
+ Deprecate Python 2.
+ Require enum34 and futures packages on Python 2.7.
+ Remove Record class and return all metadata as dict instead.
+ Add functions to parse STK, MetaSeries, ScanImage, SVS, Pilatus metadata.
+ Read tags from EXIF and GPS IFDs.
+ Use pformat for tag and metadata values.
+ Fix reading some UIC tags.
+ Do not modify input array in imshow (fix).
+ Fix Python implementation of unpack_ints.
+2017.5.23
+ Write correct number of SampleFormat values (fix).
+ Use Adobe deflate code to write ZIP compressed files.
+ Add option to pass tag values as packed binary data for writing.
+ Defer tag validation to attribute access.
+ Use property instead of lazyattr decorator for simple expressions.
+2017.3.17
+ Write IFDs and tag values on word boundaries.
+ Read ScanImage metadata.
+ Remove is_rgb and is_indexed attributes from TiffFile.
+ Create files used by doctests.
+2017.1.12 (included with scikit-image 0.14.x)
+ Read Zeiss SEM metadata.
+ Read OME-TIFF with invalid references to external files.
+ Rewrite C LZW decoder (5x faster).
+ Read corrupted LSM files missing EOI code in LZW stream.
+2017.1.1
+ Add option to append images to existing TIFF files.
+ Read files without pages.
+ Read S-FEG and Helios NanoLab tags created by FEI software.
+ Allow saving Color Filter Array (CFA) images.
+ Add info functions returning more information about TiffFile and TiffPage.
+ Add option to read specific pages only.
+ Remove maxpages argument (breaking).
+ Remove test_tifffile function.
+2016.10.28
+ Improve detection of ImageJ hyperstacks.
+ Read TVIPS metadata created by EM-MENU (by Marco Oster).
+ Add option to disable using OME-XML metadata.
+ Allow non-integer range attributes in modulo tags (by Stuart Berg).
+2016.6.21
+ Do not always memmap contiguous data in page series.
+2016.5.13
+ Add option to specify resolution unit.
+ Write grayscale images with extra samples when planarconfig is specified.
+ Do not write RGB color images with 2 samples.
+ Reorder TiffWriter.save keyword arguments (breaking).
+2016.4.18
+ TiffWriter, imread, and imsave accept open binary file streams.
+2016.04.13
+ Fix reversed fill order in 2 and 4 bps images.
+ Implement reverse_bitorder in C.
+2016.03.18
+ Fix saving additional ImageJ metadata.
+2016.2.22
+ Write 8 bytes double tag values using offset if necessary (bug fix).
+ Add option to disable writing second image description tag.
+ Detect tags with incorrect counts.
+ Disable color mapping for LSM.
+2015.11.13
+ Read LSM 6 mosaics.
+ Add option to specify directory of memory-mapped files.
+ Add command line options to specify vmin and vmax values for colormapping.
+2015.10.06
+ New helper function to apply colormaps.
+ Renamed is_palette attributes to is_indexed (breaking).
+ Color-mapped samples are now contiguous (breaking).
+ Do not color-map ImageJ hyperstacks (breaking).
+ Towards reading Leica SCN.
+2015.9.25
+ Read images with reversed bit order (FillOrder is LSB2MSB).
+2015.9.21
+ Read RGB OME-TIFF.
+ Warn about malformed OME-XML.
+2015.9.16
+ Detect some corrupted ImageJ metadata.
+ Better axes labels for 'shaped' files.
+ Do not create TiffTag for default values.
+ Chroma subsampling is not supported.
+ Memory-map data in TiffPageSeries if possible (optional).
+2015.8.17
+ Write ImageJ hyperstacks (optional).
+ Read and write LZMA compressed data.
+ Specify datetime when saving (optional).
+ Save tiled and color-mapped images (optional).
+ Ignore void bytecounts and offsets if possible.
+ Ignore bogus image_depth tag created by ISS Vista software.
+ Decode floating-point horizontal differencing (not tiled).
+ Save image data contiguously if possible.
+ Only read first IFD from ImageJ files if possible.
+ Read ImageJ 'raw' format (files larger than 4 GB).
+ TiffPageSeries class for pages with compatible shape and data type.
+ Try to read incomplete tiles.
+ Open file dialog if no filename is passed on command line.
+ Ignore errors when decoding OME-XML.
+ Rename decoder functions (breaking).
+2014.8.24
+ TiffWriter class for incremental writing images.
+ Simplify examples.
+2014.8.19
+ Add memmap function to FileHandle.
+ Add function to determine if image data in TiffPage is memory-mappable.
+ Do not close files if multifile_close parameter is False.
+2014.8.10
+ Return all extrasamples by default (breaking).
+ Read data from series of pages into memory-mapped array (optional).
+ Squeeze OME dimensions (breaking).
+ Workaround missing EOI code in strips.
+ Support image and tile depth tags (SGI extension).
+ Better handling of STK/UIC tags (breaking).
+ Disable color mapping for STK.
+ Julian to datetime converter.
+ TIFF ASCII type may be NULL separated.
+ Unwrap strip offsets for LSM files greater than 4 GB.
+ Correct strip byte counts in compressed LSM files.
+ Skip missing files in OME series.
+ Read embedded TIFF files.
+2014.2.05
+ Save rational numbers as type 5 (bug fix).
+2013.12.20
+ Keep other files in OME multi-file series closed.
+ FileHandle class to abstract binary file handle.
+ Disable color mapping for bad OME-TIFF produced by bio-formats.
+ Read bad OME-XML produced by ImageJ when cropping.
+2013.11.3
+ Allow zlib compress data in imsave function (optional).
+ Memory-map contiguous image data (optional).
+2013.10.28
+ Read MicroManager metadata and little-endian ImageJ tag.
+ Save extra tags in imsave function.
+ Save tags in ascending order by code (bug fix).
+2012.10.18
+ Accept file like objects (read from OIB files).
+2012.8.21
+ Rename TIFFfile to TiffFile and TIFFpage to TiffPage.
+ TiffSequence class for reading sequence of TIFF files.
+ Read UltraQuant tags.
+ Allow float numbers as resolution in imsave function.
+2012.8.3
+ Read MD GEL tags and NIH Image header.
+2012.7.25
+ Read ImageJ tags.
+ ...
\ No newline at end of file
=====================================
LICENSE
=====================================
@@ -1,21 +1,21 @@
-Copyright (c) 2008-2018, Christoph Gohlke
-Copyright (c) 2008-2018, The Regents of the University of California
-Produced at the Laboratory for Fluorescence Dynamics
+BSD 3-Clause License
+
+Copyright (c) 2008-2020, Christoph Gohlke
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
-* Redistributions of source code must retain the above copyright notice,
- this list of conditions and the following disclaimer.
+1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
-* Redistributions in binary form must reproduce the above copyright notice,
- this list of conditions and the following disclaimer in the documentation
- and/or other materials provided with the distribution.
+2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
-* Neither the name of the copyright holder nor the names of its
- contributors may be used to endorse or promote products derived from
- this software without specific prior written permission.
+3. Neither the name of the copyright holder nor the names of its
+ contributors may be used to endorse or promote products derived from
+ this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
=====================================
MANIFEST.in
=====================================
@@ -1,8 +1,10 @@
include LICENSE
include README.rst
+include CHANGES.rst
+include ACKNOWLEDGEMENTS.rst
-include tiffile.py
-include setup_tiffile.py
+# include tiffile.py
+# include setup_tiffile.py
include tests/*.py
recursive-exclude * __pycache__
=====================================
PKG-INFO
=====================================
@@ -1,6 +1,6 @@
Metadata-Version: 2.1
Name: tifffile
-Version: 2018.11.28
+Version: 2020.5.11
Summary: Read and write TIFF(r) files
Home-page: https://www.lfd.uci.edu/~gohlke/
Author: Christoph Gohlke
@@ -12,29 +12,29 @@ Description: Read and write TIFF(r) files
Tifffile is a Python library to
(1) store numpy arrays in TIFF (Tagged Image File Format) files, and
- (2) read image and metadata from TIFF like files used in bioimaging.
+ (2) read image and metadata from TIFF-like files used in bioimaging.
- Image and metadata can be read from TIFF, BigTIFF, OME-TIFF, STK, LSM, NIH,
- SGI, ImageJ, MicroManager, FluoView, ScanImage, SEQ, GEL, SVS, SCN, SIS, ZIF,
- QPI, and GeoTIFF files.
+ Image and metadata can be read from TIFF, BigTIFF, OME-TIFF, STK, LSM, SGI,
+ NIHImage, ImageJ, MicroManager, FluoView, ScanImage, SEQ, GEL, SVS, SCN, SIS,
+ ZIF, QPTIFF, NDPI, and GeoTIFF files.
Numpy arrays can be written to TIFF, BigTIFF, and ImageJ hyperstack compatible
files in multi-page, memory-mappable, tiled, predicted, or compressed form.
- Only a subset of the TIFF specification is supported, mainly uncompressed and
- losslessly compressed 1, 8, 16, 32 and 64-bit integer, 16, 32 and 64-bit float,
- grayscale and RGB(A) images.
+ A subset of the TIFF specification is supported, mainly uncompressed and
+ losslessly compressed 8, 16, 32 and 64-bit integer, 16, 32 and 64-bit float,
+ grayscale and multi-sample images.
Specifically, reading slices of image data, CCITT and OJPEG compression,
- chroma subsampling without JPEG compression, or IPTC and XMP metadata are not
- implemented.
+ chroma subsampling without JPEG compression, color space transformations,
+ samples with differing types, or IPTC and XMP metadata are not implemented.
TIFF(r), the Tagged Image File Format, is a trademark and under control of
- Adobe Systems Incorporated. BigTIFF allows for files greater than 4 GB.
- STK, LSM, FluoView, SGI, SEQ, GEL, and OME-TIFF, are custom extensions
- defined by Molecular Devices (Universal Imaging Corporation), Carl Zeiss
- MicroImaging, Olympus, Silicon Graphics International, Media Cybernetics,
- Molecular Dynamics, and the Open Microscopy Environment consortium
- respectively.
+ Adobe Systems Incorporated. BigTIFF allows for files larger than 4 GB.
+ STK, LSM, FluoView, SGI, SEQ, GEL, QPTIFF, NDPI, and OME-TIFF, are custom
+ extensions defined by Molecular Devices (Universal Imaging Corporation),
+ Carl Zeiss MicroImaging, Olympus, Silicon Graphics International,
+ Media Cybernetics, Molecular Dynamics, PerkinElmer, Hamamatsu, and the
+ Open Microscopy Environment consortium respectively.
For command line usage run ``python -m tifffile --help``
@@ -44,29 +44,148 @@ Description: Read and write TIFF(r) files
:Organization:
Laboratory for Fluorescence Dynamics, University of California, Irvine
- :Version: 2018.11.28
+ :License: BSD 3-Clause
+
+ :Version: 2020.5.11
Requirements
------------
- * `CPython 2.7 or 3.5+ 64-bit <https://www.python.org>`_
- * `Numpy 1.14 <https://www.numpy.org>`_
- * `Imagecodecs 2018.11.8 <https://pypi.org/project/imagecodecs/>`_
- (optional; used for decoding LZW, JPEG, etc.)
- * `Matplotlib 2.2 <https://www.matplotlib.org>`_ (optional; used for plotting)
- * Python 2.7 requires 'futures', 'enum34', and 'pathlib'.
+ This release has been tested with the following requirements and dependencies
+ (other versions may work):
+
+ * `CPython 3.6.8, 3.7.7, 3.8.2 64-bit <https://www.python.org>`_
+ * `Numpy 1.16.6 <https://www.numpy.org>`_
+ * `Imagecodecs 2020.2.18 <https://pypi.org/project/imagecodecs/>`_
+ (required only for encoding or decoding LZW, JPEG, etc.)
+ * `Matplotlib 3.1 <https://www.matplotlib.org>`_ (required only for plotting)
Revisions
---------
+ 2020.5.11
+ Pass 2908 tests.
+ Fix reading ImageJ grayscale mode RGB images (#6).
+ Remove napari reader plugin.
+ 2020.5.7
+ Add napari reader plugin (tentative).
+ Fix writing single tiles larger than image data (#3).
+ Always store ExtraSamples values in tuple (breaking).
+ 2020.5.5
+ Allow to write tiled TIFF from iterator of tiles (WIP).
+ Add function to iterate over decoded segments of TiffPage (WIP).
+ Pass chunks of segments to ThreadPoolExecutor.map to reduce memory usage.
+ Fix reading invalid files with too many strips.
+ Fix writing over-aligned image data.
+ Detect OME-XML without declaration (#2).
+ Support LERC compression (WIP).
+ Delay load imagecodecs functions.
+ Remove maxsize parameter from asarray (breaking).
+ Deprecate ijmetadata parameter from TiffWriter.save (use metadata).
+ 2020.2.16
+ Add function to decode individual strips or tiles.
+ Read strips and tiles in order of their offsets.
+ Enable multi-threading when decompressing multiple strips.
+ Replace TiffPage.tags dictionary with TiffTags (breaking).
+ Replace TIFF.TAGS dictionary with TiffTagRegistry.
+ Remove TIFF.TAG_NAMES (breaking).
+ Improve handling of TiffSequence parameters in imread.
+ Match last uncommon parts of file paths to FileSequence pattern (breaking).
+ Allow letters in FileSequence pattern for indexing well plate rows.
+ Allow to reorder axes in FileSequence.
+ Allow to write > 4 GB arrays to plain TIFF when using compression.
+ Allow to write zero size numpy arrays to nonconformant TIFF (tentative).
+ Fix xml2dict.
+ Require imagecodecs >= 2020.1.31.
+ Remove support for imagecodecs-lite (breaking).
+ Remove verify parameter to asarray function (breaking).
+ Remove deprecated lzw_decode functions (breaking).
+ Remove support for Python 2.7 and 3.5 (breaking).
+ 2019.7.26
+ Fix infinite loop reading more than two tags of same code in IFD.
+ Delay import of logging module.
+ 2019.7.20
+ Fix OME-XML detection for files created by Imaris.
+ Remove or replace assert statements.
+ 2019.7.2
+ Do not write SampleFormat tag for unsigned data types.
+ Write ByteCount tag values as SHORT or LONG if possible.
+ Allow to specify axes in FileSequence pattern via group names.
+ Add option to concurrently read FileSequence using threads.
+ Derive TiffSequence from FileSequence.
+ Use str(datetime.timedelta) to format Timer duration.
+ Use perf_counter for Timer if possible.
+ 2019.6.18
+ Fix reading planar RGB ImageJ files created by Bio-Formats.
+ Fix reading single-file, multi-image OME-TIFF without UUID.
+ Presume LSM stores uncompressed images contiguously per page..
+ Reformat some complex expressions.
+ 2019.5.30
+ Ignore invalid frames in OME-TIFF.
+ Set default subsampling to (2, 2) for RGB JPEG compression.
+ Fix reading and writing planar RGB JPEG compression.
+ Replace buffered_read with FileHandle.read_segments.
+ Include page or frame numbers in exceptions and warnings.
+ Add Timer class.
+ 2019.5.22
+ Add optional chroma subsampling for JPEG compression.
+ Enable writing PNG, JPEG, JPEGXR, and JPEG2K compression (WIP).
+ Fix writing tiled images with WebP compression.
+ Improve handling GeoTIFF sparse files.
+ 2019.3.18
+ Fix regression decoding JPEG with RGB photometrics.
+ Fix reading OME-TIFF files with corrupted but unused pages.
+ Allow to load TiffFrame without specifying keyframe.
+ Calculate virtual TiffFrames for non-BigTIFF ScanImage files > 2GB.
+ Rename property is_chroma_subsampled to is_subsampled (breaking).
+ Make more attributes and methods private (WIP).
+ 2019.3.8
+ Fix MemoryError when RowsPerStrip > ImageLength.
+ Fix SyntaxWarning on Python 3.8.
+ Fail to decode JPEG to planar RGB (tentative).
+ Separate public from private test files (WIP).
+ Allow testing without data files or imagecodecs.
+ 2019.2.22
+ Use imagecodecs-lite as a fallback for imagecodecs.
+ Simplify reading numpy arrays from file.
+ Use TiffFrames when reading arrays from page sequences.
+ Support slices and iterators in TiffPageSeries sequence interface.
+ Auto-detect uniform series.
+ Use page hash to determine generic series.
+ Turn off TiffPages cache (tentative).
+ Pass through more parameters in imread.
+ Discontinue movie parameter in imread and TiffFile (breaking).
+ Discontinue bigsize parameter in imwrite (breaking).
+ Raise TiffFileError in case of issues with TIFF structure.
+ Return TiffFile.ome_metadata as XML (breaking).
+ Ignore OME series when last dimensions are not stored in TIFF pages.
+ 2019.2.10
+ Assemble IFDs in memory to speed-up writing on some slow media.
+ Handle discontinued arguments fastij, multifile_close, and pages.
+ 2019.1.30
+ Use black background in imshow.
+ Do not write datetime tag by default (breaking).
+ Fix OME-TIFF with SamplesPerPixel > 1.
+ Allow 64-bit IFD offsets for NDPI (files > 4GB still not supported).
+ 2019.1.4
+ Fix decoding deflate without imagecodecs.
+ 2019.1.1
+ Update copyright year.
+ Require imagecodecs >= 2018.12.16.
+ Do not use JPEG tables from keyframe.
+ Enable decoding large JPEG in NDPI.
+ Decode some old-style JPEG.
+ Reorder OME channel axis to match PlanarConfiguration storage.
+ Return tiled images as contiguous arrays.
+ Add decode_lzw proxy function for compatibility with old czifile module.
+ Use dedicated logger.
2018.11.28
- Pass 2739 tests.
Make SubIFDs accessible as TiffPage.pages.
- Make parsing of TiffSequence axes pattern optional (backward incompatible).
+ Make parsing of TiffSequence axes pattern optional (breaking).
Limit parsing of TiffSequence axes pattern to file names, not path names.
Do not interpolate in imshow if image dimensions <= 512, else use bilinear.
Use logging.warning instead of warnings.warn in many cases.
Fix numpy FutureWarning for out == 'memmap'.
Adjust ZSTD and WebP compression to libtiff-4.0.10 (WIP).
- Decode old style LZW with imagecodecs >= 2018.11.8.
+ Decode old-style LZW with imagecodecs >= 2018.11.8.
Remove TiffFile.qptiff_metadata (QPI metadata are per page).
Do not use keyword arguments before variable positional arguments.
Make either all or none return statements in a function return expression.
@@ -75,323 +194,117 @@ Description: Read and write TIFF(r) files
2018.11.6
Rename imsave function to imwrite.
Readd Python implementations of packints, delta, and bitorder codecs.
- Fix TiffFrame.compression AttributeError (bug fix).
+ Fix TiffFrame.compression AttributeError.
2018.10.18
- Rename tiffile package to tifffile.
- 2018.10.10
- Pass 2710 tests.
- Read ZIF, the Zoomable Image Format (WIP).
- Decode YCbCr JPEG as RGB (tentative).
- Improve restoration of incomplete tiles.
- Allow to write grayscale with extrasamples without specifying planarconfig.
- Enable decoding of PNG and JXR via imagecodecs.
- Deprecate 32-bit platforms (too many memory errors during tests).
- 2018.9.27
- Read Olympus SIS (WIP).
- Allow to write non-BigTIFF files up to ~4 GB (bug fix).
- Fix parsing date and time fields in SEM metadata (bug fix).
- Detect some circular IFD references.
- Enable WebP codecs via imagecodecs.
- Add option to read TiffSequence from ZIP containers.
- Remove TiffFile.isnative.
- Move TIFF struct format constants out of TiffFile namespace.
- 2018.8.31
- Pass 2699 tests.
- Fix wrong TiffTag.valueoffset (bug fix).
- Towards reading Hamamatsu NDPI (WIP).
- Enable PackBits compression of byte and bool arrays.
- Fix parsing NULL terminated CZ_SEM strings.
- 2018.8.24
- Move tifffile.py and related modules into tiffile package.
- Move usage examples to module docstring.
- Enable multi-threading for compressed tiles and pages by default.
- Add option to concurrently decode image tiles using threads.
- Do not skip empty tiles (bug fix).
- Read JPEG and J2K compressed strips and tiles.
- Allow floating point predictor on write.
- Add option to specify subfiletype on write.
- Depend on imagecodecs package instead of _tifffile, lzma, etc modules.
- Remove reverse_bitorder, unpack_ints, and decode functions.
- Use pytest instead of unittest.
- 2018.6.20
- Save RGBA with unassociated extrasample by default (backward incompatible).
- Add option to specify ExtraSamples values.
- 2018.6.17
- Pass 2680 tests.
- Towards reading JPEG and other compressions via imagecodecs package (WIP).
- Read SampleFormat VOID as UINT.
- Add function to validate TIFF using 'jhove -m TIFF-hul'.
- Save bool arrays as bilevel TIFF.
- Accept pathlib.Path as filenames.
- Move 'software' argument from TiffWriter __init__ to save.
- Raise DOS limit to 16 TB.
- Lazy load lzma and zstd compressors and decompressors.
- Add option to save IJMetadata tags.
- Return correct number of pages for truncated series (bug fix).
- Move EXIF tags to TIFF.TAG as per TIFF/EP standard.
- 2018.2.18
- Pass 2293 tests.
- Always save RowsPerStrip and Resolution tags as required by TIFF standard.
- Do not use badly typed ImageDescription.
- Coherce bad ASCII string tags to bytes.
- Tuning of __str__ functions.
- Fix reading 'undefined' tag values (bug fix).
- Read and write ZSTD compressed data.
- Use hexdump to print byte strings.
- Determine TIFF byte order from data dtype in imsave.
- Add option to specify RowsPerStrip for compressed strips.
- Allow memory-map of arrays with non-native byte order.
- Attempt to handle ScanImage <= 5.1 files.
- Restore TiffPageSeries.pages sequence interface.
- Use numpy.frombuffer instead of fromstring to read from binary data.
- Parse GeoTIFF metadata.
- Add option to apply horizontal differencing before compression.
- Towards reading PerkinElmer QPI (QPTIFF, no test files).
- Do not index out of bounds data in tifffile.c unpackbits and decodelzw.
- 2017.9.29 (tentative)
- Many backward incompatible changes improving speed and resource usage:
- Pass 2268 tests.
- Add detail argument to __str__ function. Remove info functions.
- Fix potential issue correcting offsets of large LSM files with positions.
- Remove TiffFile sequence interface; use TiffFile.pages instead.
- Do not make tag values available as TiffPage attributes.
- Use str (not bytes) type for tag and metadata strings (WIP).
- Use documented standard tag and value names (WIP).
- Use enums for some documented TIFF tag values.
- Remove 'memmap' and 'tmpfile' options; use out='memmap' instead.
- Add option to specify output in asarray functions.
- Add option to concurrently decode pages using threads.
- Add TiffPage.asrgb function (WIP).
- Do not apply colormap in asarray.
- Remove 'colormapped', 'rgbonly', and 'scale_mdgel' options from asarray.
- Consolidate metadata in TiffFile _metadata functions.
- Remove non-tag metadata properties from TiffPage.
- Add function to convert LSM to tiled BIN files.
- Align image data in file.
- Make TiffPage.dtype a numpy.dtype.
- Add 'ndim' and 'size' properties to TiffPage and TiffPageSeries.
- Allow imsave to write non-BigTIFF files up to ~4 GB.
- Only read one page for shaped series if possible.
- Add memmap function to create memory-mapped array stored in TIFF file.
- Add option to save empty arrays to TIFF files.
- Add option to save truncated TIFF files.
- Allow single tile images to be saved contiguously.
- Add optional movie mode for files with uniform pages.
- Lazy load pages.
- Use lightweight TiffFrame for IFDs sharing properties with key TiffPage.
- Move module constants to 'TIFF' namespace (speed up module import).
- Remove 'fastij' option from TiffFile.
- Remove 'pages' parameter from TiffFile.
- Remove TIFFfile alias.
- Deprecate Python 2.
- Require enum34 and futures packages on Python 2.7.
- Remove Record class and return all metadata as dict instead.
- Add functions to parse STK, MetaSeries, ScanImage, SVS, Pilatus metadata.
- Read tags from EXIF and GPS IFDs.
- Use pformat for tag and metadata values.
- Fix reading some UIC tags (bug fix).
- Do not modify input array in imshow (bug fix).
- Fix Python implementation of unpack_ints.
- 2017.5.23
- Pass 1961 tests.
- Write correct number of SampleFormat values (bug fix).
- Use Adobe deflate code to write ZIP compressed files.
- Add option to pass tag values as packed binary data for writing.
- Defer tag validation to attribute access.
- Use property instead of lazyattr decorator for simple expressions.
- 2017.3.17
- Write IFDs and tag values on word boundaries.
- Read ScanImage metadata.
- Remove is_rgb and is_indexed attributes from TiffFile.
- Create files used by doctests.
- 2017.1.12
- Read Zeiss SEM metadata.
- Read OME-TIFF with invalid references to external files.
- Rewrite C LZW decoder (5x faster).
- Read corrupted LSM files missing EOI code in LZW stream.
- 2017.1.1
- Add option to append images to existing TIFF files.
- Read files without pages.
- Read S-FEG and Helios NanoLab tags created by FEI software.
- Allow saving Color Filter Array (CFA) images.
- Add info functions returning more information about TiffFile and TiffPage.
- Add option to read specific pages only.
- Remove maxpages argument (backward incompatible).
- Remove test_tifffile function.
- 2016.10.28
- Pass 1944 tests.
- Improve detection of ImageJ hyperstacks.
- Read TVIPS metadata created by EM-MENU (by Marco Oster).
- Add option to disable using OME-XML metadata.
- Allow non-integer range attributes in modulo tags (by Stuart Berg).
- 2016.6.21
- Do not always memmap contiguous data in page series.
- 2016.5.13
- Add option to specify resolution unit.
- Write grayscale images with extra samples when planarconfig is specified.
- Do not write RGB color images with 2 samples.
- Reorder TiffWriter.save keyword arguments (backward incompatible).
- 2016.4.18
- Pass 1932 tests.
- TiffWriter, imread, and imsave accept open binary file streams.
- 2016.04.13
- Correctly handle reversed fill order in 2 and 4 bps images (bug fix).
- Implement reverse_bitorder in C.
- 2016.03.18
- Fix saving additional ImageJ metadata.
- 2016.2.22
- Pass 1920 tests.
- Write 8 bytes double tag values using offset if necessary (bug fix).
- Add option to disable writing second image description tag.
- Detect tags with incorrect counts.
- Disable color mapping for LSM.
- 2015.11.13
- Read LSM 6 mosaics.
- Add option to specify directory of memory-mapped files.
- Add command line options to specify vmin and vmax values for colormapping.
- 2015.10.06
- New helper function to apply colormaps.
- Renamed is_palette attributes to is_indexed (backward incompatible).
- Color-mapped samples are now contiguous (backward incompatible).
- Do not color-map ImageJ hyperstacks (backward incompatible).
- Towards reading Leica SCN.
- 2015.9.25
- Read images with reversed bit order (FillOrder is LSB2MSB).
- 2015.9.21
- Read RGB OME-TIFF.
- Warn about malformed OME-XML.
- 2015.9.16
- Detect some corrupted ImageJ metadata.
- Better axes labels for 'shaped' files.
- Do not create TiffTag for default values.
- Chroma subsampling is not supported.
- Memory-map data in TiffPageSeries if possible (optional).
- 2015.8.17
- Pass 1906 tests.
- Write ImageJ hyperstacks (optional).
- Read and write LZMA compressed data.
- Specify datetime when saving (optional).
- Save tiled and color-mapped images (optional).
- Ignore void bytecounts and offsets if possible.
- Ignore bogus image_depth tag created by ISS Vista software.
- Decode floating point horizontal differencing (not tiled).
- Save image data contiguously if possible.
- Only read first IFD from ImageJ files if possible.
- Read ImageJ 'raw' format (files larger than 4 GB).
- TiffPageSeries class for pages with compatible shape and data type.
- Try to read incomplete tiles.
- Open file dialog if no filename is passed on command line.
- Ignore errors when decoding OME-XML.
- Rename decoder functions (backward incompatible).
- 2014.8.24
- TiffWriter class for incremental writing images.
- Simplify examples.
- 2014.8.19
- Add memmap function to FileHandle.
- Add function to determine if image data in TiffPage is memory-mappable.
- Do not close files if multifile_close parameter is False.
- 2014.8.10
- Pass 1730 tests.
- Return all extrasamples by default (backward incompatible).
- Read data from series of pages into memory-mapped array (optional).
- Squeeze OME dimensions (backward incompatible).
- Workaround missing EOI code in strips.
- Support image and tile depth tags (SGI extension).
- Better handling of STK/UIC tags (backward incompatible).
- Disable color mapping for STK.
- Julian to datetime converter.
- TIFF ASCII type may be NULL separated.
- Unwrap strip offsets for LSM files greater than 4 GB.
- Correct strip byte counts in compressed LSM files.
- Skip missing files in OME series.
- Read embedded TIFF files.
- 2014.2.05
- Save rational numbers as type 5 (bug fix).
- 2013.12.20
- Keep other files in OME multi-file series closed.
- FileHandle class to abstract binary file handle.
- Disable color mapping for bad OME-TIFF produced by bio-formats.
- Read bad OME-XML produced by ImageJ when cropping.
- 2013.11.3
- Allow zlib compress data in imsave function (optional).
- Memory-map contiguous image data (optional).
- 2013.10.28
- Read MicroManager metadata and little-endian ImageJ tag.
- Save extra tags in imsave function.
- Save tags in ascending order by code (bug fix).
- 2012.10.18
- Accept file like objects (read from OIB files).
- 2012.8.21
- Rename TIFFfile to TiffFile and TIFFpage to TiffPage.
- TiffSequence class for reading sequence of TIFF files.
- Read UltraQuant tags.
- Allow float numbers as resolution in imsave function.
- 2012.8.3
- Read MD GEL tags and NIH Image header.
- 2012.7.25
- Read ImageJ tags.
...
+ Refer to the CHANGES file for older revisions.
+
Notes
-----
The API is not stable yet and might change between revisions.
Tested on little-endian platforms only.
- Python 2.7, 3.4, and 32-bit versions are deprecated.
+ Python 32-bit versions are deprecated.
+
+ Update pip and setuptools to the latest version before installing tifffile:
+
+ ``python -m pip install --upgrade pip setuptools``
+
+ Tifffile relies on the `imagecodecs <https://pypi.org/project/imagecodecs/>`_
+ package for encoding and decoding LZW, JPEG, and other compressed images.
+
+ Several TIFF-like formats do not strictly adhere to the TIFF6 specification,
+ some of which allow file or data sizes to exceed the 4 GB limit:
+
+ * *BigTIFF* is identified by version number 43 and uses different file
+ header, IFD, and tag structures with 64-bit offsets. It adds more data types.
+ Tifffile can read and write BigTIFF files.
+ * *ImageJ* hyperstacks store all image data, which may exceed 4 GB,
+ contiguously after the first IFD. Files > 4 GB contain one IFD only.
+ The size (shape and dtype) of the up to 6-dimensional image data can be
+ determined from the ImageDescription tag of the first IFD, which is Latin-1
+ encoded. Tifffile can read and write ImageJ hyperstacks.
+ * *OME-TIFF* stores up to 8-dimensional data in one or multiple TIFF of BigTIFF
+ files. The 8-bit UTF-8 encoded OME-XML metadata found in the ImageDescription
+ tag of the first IFD defines the position of TIFF IFDs in the high
+ dimensional data. Tifffile can read OME-TIFF files, except when the OME-XML
+ metadata are stored in a separate file.
+ * *LSM* stores all IFDs below 4 GB but wraps around 32-bit StripOffsets.
+ The StripOffsets of each series and position require separate unwrapping.
+ The StripByteCounts tag contains the number of bytes for the uncompressed
+ data. Tifffile can read large LSM files.
+ * *NDPI* uses some 64-bit offsets in the file header, IFD, and tag structures.
+ Tag values/offsets can be corrected using high bits stored after IFD
+ structures. JPEG compressed tiles with dimensions > 65536 are not readable
+ with libjpeg. Tifffile can read NDPI files < 4 GB and decompress large JPEG
+ tiles using the imagecodecs library on Windows.
+ * *ScanImage* optionally allows corrupt non-BigTIFF files > 2 GB. The values
+ of StripOffsets and StripByteCounts can be recovered using the constant
+ differences of the offsets of IFD and tag values throughout the file.
+ Tifffile can read such files on Python 3 if the image data are stored
+ contiguously in each page.
+ * *GeoTIFF* sparse files allow strip or tile offsets and byte counts to be 0.
+ Such segments are implicitly set to 0 or the NODATA value on reading.
+ Tifffile can read GeoTIFF sparse files.
Other libraries for reading scientific TIFF files from Python:
- * `Python-bioformats <https://github.com/CellProfiler/python-bioformats>`_
- * `Imread <https://github.com/luispedro/imread>`_
- * `GDAL <https://github.com/OSGeo/gdal/tree/master/gdal/swig/python>`_
- * `OpenSlide-python <https://github.com/openslide/openslide-python>`_
- * `PyLibTiff <https://github.com/pearu/pylibtiff>`_
- * `SimpleITK <http://www.simpleitk.org>`_
- * `PyLSM <https://launchpad.net/pylsm>`_
- * `PyMca.TiffIO.py <https://github.com/vasole/pymca>`_ (same as fabio.TiffIO)
- * `BioImageXD.Readers <http://www.bioimagexd.net/>`_
- * `Cellcognition.io <http://cellcognition.org/>`_
- * `pymimage <https://github.com/ardoi/pymimage>`_
- * `pytiff <https://github.com/FZJ-INM1-BDA/pytiff>`_
-
- Acknowledgements
- ----------------
- * Egor Zindy, University of Manchester, for lsm_scan_info specifics.
- * Wim Lewis for a bug fix and some LSM functions.
- * Hadrien Mary for help on reading MicroManager files.
- * Christian Kliche for help writing tiled and color-mapped files.
+ * `Python-bioformats <https://github.com/CellProfiler/python-bioformats>`_
+ * `Imread <https://github.com/luispedro/imread>`_
+ * `GDAL <https://github.com/OSGeo/gdal/tree/master/gdal/swig/python>`_
+ * `OpenSlide-python <https://github.com/openslide/openslide-python>`_
+ * `PyLibTiff <https://github.com/pearu/pylibtiff>`_
+ * `SimpleITK <https://github.com/SimpleITK/SimpleITK>`_
+ * `PyLSM <https://launchpad.net/pylsm>`_
+ * `PyMca.TiffIO.py <https://github.com/vasole/pymca>`_ (same as fabio.TiffIO)
+ * `BioImageXD.Readers <http://www.bioimagexd.net/>`_
+ * `CellCognition <https://cellcognition-project.org/>`_
+ * `pymimage <https://github.com/ardoi/pymimage>`_
+ * `pytiff <https://github.com/FZJ-INM1-BDA/pytiff>`_
+ * `ScanImageTiffReaderPython
+ <https://gitlab.com/vidriotech/scanimagetiffreader-python>`_
+ * `bigtiff <https://pypi.org/project/bigtiff>`_
+
+ Some libraries are using tifffile to write OME-TIFF files:
+
+ * `Zeiss Apeer OME-TIFF library
+ <https://github.com/apeer-micro/apeer-ometiff-library>`_
+ * `Allen Institute for Cell Science imageio
+ <https://pypi.org/project/aicsimageio>`_
References
----------
- 1) TIFF 6.0 Specification and Supplements. Adobe Systems Incorporated.
+ 1. TIFF 6.0 Specification and Supplements. Adobe Systems Incorporated.
https://www.adobe.io/open/standards/TIFF.html
- 2) TIFF File Format FAQ. https://www.awaresystems.be/imaging/tiff/faq.html
- 3) MetaMorph Stack (STK) Image File Format.
+ 2. TIFF File Format FAQ. https://www.awaresystems.be/imaging/tiff/faq.html
+ 3. MetaMorph Stack (STK) Image File Format.
http://mdc.custhelp.com/app/answers/detail/a_id/18862
- 4) Image File Format Description LSM 5/7 Release 6.0 (ZEN 2010)..
+ 4. Image File Format Description LSM 5/7 Release 6.0 (ZEN 2010)..
Carl Zeiss MicroImaging GmbH. BioSciences. May 10, 2011
- 5) The OME-TIFF format.
+ 5. The OME-TIFF format.
https://docs.openmicroscopy.org/ome-model/5.6.4/ome-tiff/
- 6) UltraQuant(r) Version 6.0 for Windows Start-Up Guide.
+ 6. UltraQuant(r) Version 6.0 for Windows Start-Up Guide.
http://www.ultralum.com/images%20ultralum/pdf/UQStart%20Up%20Guide.pdf
- 7) Micro-Manager File Formats.
+ 7. Micro-Manager File Formats.
https://micro-manager.org/wiki/Micro-Manager_File_Formats
- 8) Tags for TIFF and Related Specifications. Digital Preservation.
+ 8. Tags for TIFF and Related Specifications. Digital Preservation.
https://www.loc.gov/preservation/digital/formats/content/tiff_tags.shtml
- 9) ScanImage BigTiff Specification - ScanImage 2016.
+ 9. ScanImage BigTiff Specification - ScanImage 2016.
http://scanimage.vidriotechnologies.com/display/SI2016/
ScanImage+BigTiff+Specification
- 10) CIPA DC-008-2016: Exchangeable image file format for digital still cameras:
+ 10. CIPA DC-008-2016: Exchangeable image file format for digital still cameras:
Exif Version 2.31.
http://www.cipa.jp/std/documents/e/DC-008-Translation-2016-E.pdf
- 11) ZIF, the Zoomable Image File format. http://zif.photo/
+ 11. ZIF, the Zoomable Image File format. http://zif.photo/
+ 12. GeoTIFF File Format https://gdal.org/drivers/raster/gtiff.html
Examples
--------
Save a 3D numpy array to a multi-page, 16-bit grayscale TIFF file:
- >>> data = numpy.random.randint(0, 2**16, (4, 301, 219), 'uint16')
+ >>> data = numpy.random.randint(0, 2**12, (4, 301, 219), 'uint16')
>>> imwrite('temp.tif', data, photometric='minisblack')
Read the whole image stack from the TIFF file as numpy array:
@@ -402,7 +315,7 @@ Description: Read and write TIFF(r) files
>>> image_stack.dtype
dtype('uint16')
- Read the image from first page (IFD) in the TIFF file:
+ Read the image from the first page in the TIFF file as numpy array:
>>> image = imread('temp.tif', key=0)
>>> image.shape
@@ -424,14 +337,36 @@ Description: Read and write TIFF(r) files
>>> data = numpy.random.rand(2, 5, 3, 301, 219).astype('float32')
>>> imwrite('temp.tif', data, compress=6, metadata={'axes': 'TZCYX'})
- Save a volume with xyz voxel size 2.6755x2.6755x3.9474 µm^3 to ImageJ file:
+ Save a volume with xyz voxel size 2.6755x2.6755x3.9474 micron^3 to an ImageJ
+ formatted TIFF file:
>>> volume = numpy.random.randn(57*256*256).astype('float32')
>>> volume.shape = 1, 57, 1, 256, 256, 1 # dimensions in TZCYXS order
>>> imwrite('temp.tif', volume, imagej=True, resolution=(1./2.6755, 1./2.6755),
... metadata={'spacing': 3.947368, 'unit': 'um'})
- Read hyperstack and metadata from ImageJ file:
+ Get the shape and dtype of the volume stored in the TIFF file:
+
+ >>> tif = TiffFile('temp.tif')
+ >>> len(tif.pages) # number of pages in the file
+ 57
+ >>> page = tif.pages[0] # get shape and dtype of the image in the first page
+ >>> page.shape
+ (256, 256)
+ >>> page.dtype
+ dtype('float32')
+ >>> page.axes
+ 'YX'
+ >>> series = tif.series[0] # get shape and dtype of the first image series
+ >>> series.shape
+ (57, 256, 256)
+ >>> series.dtype
+ dtype('float32')
+ >>> series.axes
+ 'ZYX'
+ >>> tif.close()
+
+ Read hyperstack and metadata from the ImageJ file:
>>> with TiffFile('temp.tif') as tif:
... imagej_hyperstack = tif.asarray()
@@ -441,35 +376,58 @@ Description: Read and write TIFF(r) files
>>> imagej_metadata['slices']
57
+ Read the "XResolution" tag from the first page in the TIFF file:
+
+ >>> with TiffFile('temp.tif') as tif:
+ ... tag = tif.pages[0].tags['XResolution']
+ >>> tag.value
+ (2000, 5351)
+ >>> tag.name
+ 'XResolution'
+ >>> tag.code
+ 282
+ >>> tag.count
+ 1
+ >>> tag.dtype
+ '2I'
+
+ Read images from a selected range of pages:
+
+ >>> image = imread('temp.tif', key=range(4, 40, 2))
+ >>> image.shape
+ (18, 256, 256)
+
Create an empty TIFF file and write to the memory-mapped numpy array:
>>> memmap_image = memmap('temp.tif', shape=(256, 256), dtype='float32')
>>> memmap_image[255, 255] = 1.0
>>> memmap_image.flush()
- >>> memmap_image.shape, memmap_image.dtype
- ((256, 256), dtype('float32'))
>>> del memmap_image
- Memory-map image data in the TIFF file:
+ Memory-map image data of the first page in the TIFF file:
>>> memmap_image = memmap('temp.tif', page=0)
>>> memmap_image[255, 255]
1.0
>>> del memmap_image
- Successively append images to a BigTIFF file:
+ Successively append images to a BigTIFF file, which can exceed 4 GB:
>>> data = numpy.random.randint(0, 255, (5, 2, 3, 301, 219), 'uint8')
>>> with TiffWriter('temp.tif', bigtiff=True) as tif:
... for i in range(data.shape[0]):
... tif.save(data[i], compress=6, photometric='minisblack')
+ Append an image to the existing TIFF file:
+
+ >>> data = numpy.random.randint(0, 255, (301, 219, 3), 'uint8')
+ >>> imwrite('temp.tif', data, append=True)
+
Iterate over pages and tags in the TIFF file and successively read images:
>>> with TiffFile('temp.tif') as tif:
- ... image_stack = tif.asarray()
... for page in tif.pages:
- ... for tag in page.tags.values():
+ ... for tag in page.tags:
... tag_name, tag_value = tag.name, tag.value
... image = page.asarray()
@@ -479,7 +437,7 @@ Description: Read and write TIFF(r) files
>>> data1 = numpy.random.randint(0, 255, (5, 301, 219), 'uint16')
>>> with TiffWriter('temp.tif') as tif:
... tif.save(data0, compress=6, photometric='rgb')
- ... tif.save(data1, compress=6, photometric='minisblack')
+ ... tif.save(data1, compress=6, photometric='minisblack', contiguous=False)
Read the second image series from the TIFF file:
@@ -487,7 +445,7 @@ Description: Read and write TIFF(r) files
>>> series1.shape
(5, 301, 219)
- Read an image stack from a sequence of TIFF files with a file name pattern:
+ Read an image stack from a series of TIFF files with a file name pattern:
>>> imwrite('temp_C001T001.tif', numpy.random.rand(64, 64))
>>> imwrite('temp_C001T002.tif', numpy.random.rand(64, 64))
@@ -500,18 +458,22 @@ Description: Read and write TIFF(r) files
>>> data.shape
(1, 2, 64, 64)
+ Create a TIFF file from an iterator of tiles:
+
+ >>> def tiles():
+ ... data = numpy.arange(3*4*16*16, dtype='uint16').reshape((3*4, 16, 16))
+ ... for i in range(data.shape[0]): yield data[i]
+ >>> imwrite('temp.tif', tiles(), dtype='uint16', shape=(48, 64), tile=(16, 16))
+
Platform: any
Classifier: Development Status :: 4 - Beta
Classifier: License :: OSI Approved :: BSD License
Classifier: Intended Audience :: Science/Research
Classifier: Intended Audience :: Developers
Classifier: Operating System :: OS Independent
-Classifier: Programming Language :: Python :: 2
-Classifier: Programming Language :: Python :: 2.7
-Classifier: Programming Language :: Python :: 3
-Classifier: Programming Language :: Python :: 3.4
-Classifier: Programming Language :: Python :: 3.5
+Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.6
Classifier: Programming Language :: Python :: 3.7
-Requires-Python: >=2.7
+Classifier: Programming Language :: Python :: 3.8
+Requires-Python: >=3.6
Provides-Extra: all
=====================================
README.rst
=====================================
@@ -4,29 +4,29 @@ Read and write TIFF(r) files
Tifffile is a Python library to
(1) store numpy arrays in TIFF (Tagged Image File Format) files, and
-(2) read image and metadata from TIFF like files used in bioimaging.
+(2) read image and metadata from TIFF-like files used in bioimaging.
-Image and metadata can be read from TIFF, BigTIFF, OME-TIFF, STK, LSM, NIH,
-SGI, ImageJ, MicroManager, FluoView, ScanImage, SEQ, GEL, SVS, SCN, SIS, ZIF,
-QPI, and GeoTIFF files.
+Image and metadata can be read from TIFF, BigTIFF, OME-TIFF, STK, LSM, SGI,
+NIHImage, ImageJ, MicroManager, FluoView, ScanImage, SEQ, GEL, SVS, SCN, SIS,
+ZIF, QPTIFF, NDPI, and GeoTIFF files.
Numpy arrays can be written to TIFF, BigTIFF, and ImageJ hyperstack compatible
files in multi-page, memory-mappable, tiled, predicted, or compressed form.
-Only a subset of the TIFF specification is supported, mainly uncompressed and
-losslessly compressed 1, 8, 16, 32 and 64-bit integer, 16, 32 and 64-bit float,
-grayscale and RGB(A) images.
+A subset of the TIFF specification is supported, mainly uncompressed and
+losslessly compressed 8, 16, 32 and 64-bit integer, 16, 32 and 64-bit float,
+grayscale and multi-sample images.
Specifically, reading slices of image data, CCITT and OJPEG compression,
-chroma subsampling without JPEG compression, or IPTC and XMP metadata are not
-implemented.
+chroma subsampling without JPEG compression, color space transformations,
+samples with differing types, or IPTC and XMP metadata are not implemented.
TIFF(r), the Tagged Image File Format, is a trademark and under control of
-Adobe Systems Incorporated. BigTIFF allows for files greater than 4 GB.
-STK, LSM, FluoView, SGI, SEQ, GEL, and OME-TIFF, are custom extensions
-defined by Molecular Devices (Universal Imaging Corporation), Carl Zeiss
-MicroImaging, Olympus, Silicon Graphics International, Media Cybernetics,
-Molecular Dynamics, and the Open Microscopy Environment consortium
-respectively.
+Adobe Systems Incorporated. BigTIFF allows for files larger than 4 GB.
+STK, LSM, FluoView, SGI, SEQ, GEL, QPTIFF, NDPI, and OME-TIFF, are custom
+extensions defined by Molecular Devices (Universal Imaging Corporation),
+Carl Zeiss MicroImaging, Olympus, Silicon Graphics International,
+Media Cybernetics, Molecular Dynamics, PerkinElmer, Hamamatsu, and the
+Open Microscopy Environment consortium respectively.
For command line usage run ``python -m tifffile --help``
@@ -36,29 +36,148 @@ For command line usage run ``python -m tifffile --help``
:Organization:
Laboratory for Fluorescence Dynamics, University of California, Irvine
-:Version: 2018.11.28
+:License: BSD 3-Clause
+
+:Version: 2020.5.11
Requirements
------------
-* `CPython 2.7 or 3.5+ 64-bit <https://www.python.org>`_
-* `Numpy 1.14 <https://www.numpy.org>`_
-* `Imagecodecs 2018.11.8 <https://pypi.org/project/imagecodecs/>`_
- (optional; used for decoding LZW, JPEG, etc.)
-* `Matplotlib 2.2 <https://www.matplotlib.org>`_ (optional; used for plotting)
-* Python 2.7 requires 'futures', 'enum34', and 'pathlib'.
+This release has been tested with the following requirements and dependencies
+(other versions may work):
+
+* `CPython 3.6.8, 3.7.7, 3.8.2 64-bit <https://www.python.org>`_
+* `Numpy 1.16.6 <https://www.numpy.org>`_
+* `Imagecodecs 2020.2.18 <https://pypi.org/project/imagecodecs/>`_
+ (required only for encoding or decoding LZW, JPEG, etc.)
+* `Matplotlib 3.1 <https://www.matplotlib.org>`_ (required only for plotting)
Revisions
---------
+2020.5.11
+ Pass 2908 tests.
+ Fix reading ImageJ grayscale mode RGB images (#6).
+ Remove napari reader plugin.
+2020.5.7
+ Add napari reader plugin (tentative).
+ Fix writing single tiles larger than image data (#3).
+ Always store ExtraSamples values in tuple (breaking).
+2020.5.5
+ Allow to write tiled TIFF from iterator of tiles (WIP).
+ Add function to iterate over decoded segments of TiffPage (WIP).
+ Pass chunks of segments to ThreadPoolExecutor.map to reduce memory usage.
+ Fix reading invalid files with too many strips.
+ Fix writing over-aligned image data.
+ Detect OME-XML without declaration (#2).
+ Support LERC compression (WIP).
+ Delay load imagecodecs functions.
+ Remove maxsize parameter from asarray (breaking).
+ Deprecate ijmetadata parameter from TiffWriter.save (use metadata).
+2020.2.16
+ Add function to decode individual strips or tiles.
+ Read strips and tiles in order of their offsets.
+ Enable multi-threading when decompressing multiple strips.
+ Replace TiffPage.tags dictionary with TiffTags (breaking).
+ Replace TIFF.TAGS dictionary with TiffTagRegistry.
+ Remove TIFF.TAG_NAMES (breaking).
+ Improve handling of TiffSequence parameters in imread.
+ Match last uncommon parts of file paths to FileSequence pattern (breaking).
+ Allow letters in FileSequence pattern for indexing well plate rows.
+ Allow to reorder axes in FileSequence.
+ Allow to write > 4 GB arrays to plain TIFF when using compression.
+ Allow to write zero size numpy arrays to nonconformant TIFF (tentative).
+ Fix xml2dict.
+ Require imagecodecs >= 2020.1.31.
+ Remove support for imagecodecs-lite (breaking).
+ Remove verify parameter to asarray function (breaking).
+ Remove deprecated lzw_decode functions (breaking).
+ Remove support for Python 2.7 and 3.5 (breaking).
+2019.7.26
+ Fix infinite loop reading more than two tags of same code in IFD.
+ Delay import of logging module.
+2019.7.20
+ Fix OME-XML detection for files created by Imaris.
+ Remove or replace assert statements.
+2019.7.2
+ Do not write SampleFormat tag for unsigned data types.
+ Write ByteCount tag values as SHORT or LONG if possible.
+ Allow to specify axes in FileSequence pattern via group names.
+ Add option to concurrently read FileSequence using threads.
+ Derive TiffSequence from FileSequence.
+ Use str(datetime.timedelta) to format Timer duration.
+ Use perf_counter for Timer if possible.
+2019.6.18
+ Fix reading planar RGB ImageJ files created by Bio-Formats.
+ Fix reading single-file, multi-image OME-TIFF without UUID.
+ Presume LSM stores uncompressed images contiguously per page.
+ Reformat some complex expressions.
+2019.5.30
+ Ignore invalid frames in OME-TIFF.
+ Set default subsampling to (2, 2) for RGB JPEG compression.
+ Fix reading and writing planar RGB JPEG compression.
+ Replace buffered_read with FileHandle.read_segments.
+ Include page or frame numbers in exceptions and warnings.
+ Add Timer class.
+2019.5.22
+ Add optional chroma subsampling for JPEG compression.
+ Enable writing PNG, JPEG, JPEGXR, and JPEG2K compression (WIP).
+ Fix writing tiled images with WebP compression.
+ Improve handling GeoTIFF sparse files.
+2019.3.18
+ Fix regression decoding JPEG with RGB photometrics.
+ Fix reading OME-TIFF files with corrupted but unused pages.
+ Allow to load TiffFrame without specifying keyframe.
+ Calculate virtual TiffFrames for non-BigTIFF ScanImage files > 2GB.
+ Rename property is_chroma_subsampled to is_subsampled (breaking).
+ Make more attributes and methods private (WIP).
+2019.3.8
+ Fix MemoryError when RowsPerStrip > ImageLength.
+ Fix SyntaxWarning on Python 3.8.
+ Fail to decode JPEG to planar RGB (tentative).
+ Separate public from private test files (WIP).
+ Allow testing without data files or imagecodecs.
+2019.2.22
+ Use imagecodecs-lite as a fallback for imagecodecs.
+ Simplify reading numpy arrays from file.
+ Use TiffFrames when reading arrays from page sequences.
+ Support slices and iterators in TiffPageSeries sequence interface.
+ Auto-detect uniform series.
+ Use page hash to determine generic series.
+ Turn off TiffPages cache (tentative).
+ Pass through more parameters in imread.
+ Discontinue movie parameter in imread and TiffFile (breaking).
+ Discontinue bigsize parameter in imwrite (breaking).
+ Raise TiffFileError in case of issues with TIFF structure.
+ Return TiffFile.ome_metadata as XML (breaking).
+ Ignore OME series when last dimensions are not stored in TIFF pages.
+2019.2.10
+ Assemble IFDs in memory to speed-up writing on some slow media.
+ Handle discontinued arguments fastij, multifile_close, and pages.
+2019.1.30
+ Use black background in imshow.
+ Do not write datetime tag by default (breaking).
+ Fix OME-TIFF with SamplesPerPixel > 1.
+ Allow 64-bit IFD offsets for NDPI (files > 4GB still not supported).
+2019.1.4
+ Fix decoding deflate without imagecodecs.
+2019.1.1
+ Update copyright year.
+ Require imagecodecs >= 2018.12.16.
+ Do not use JPEG tables from keyframe.
+ Enable decoding large JPEG in NDPI.
+ Decode some old-style JPEG.
+ Reorder OME channel axis to match PlanarConfiguration storage.
+ Return tiled images as contiguous arrays.
+ Add decode_lzw proxy function for compatibility with old czifile module.
+ Use dedicated logger.
2018.11.28
- Pass 2739 tests.
Make SubIFDs accessible as TiffPage.pages.
- Make parsing of TiffSequence axes pattern optional (backward incompatible).
+ Make parsing of TiffSequence axes pattern optional (breaking).
Limit parsing of TiffSequence axes pattern to file names, not path names.
Do not interpolate in imshow if image dimensions <= 512, else use bilinear.
Use logging.warning instead of warnings.warn in many cases.
Fix numpy FutureWarning for out == 'memmap'.
Adjust ZSTD and WebP compression to libtiff-4.0.10 (WIP).
- Decode old style LZW with imagecodecs >= 2018.11.8.
+ Decode old-style LZW with imagecodecs >= 2018.11.8.
Remove TiffFile.qptiff_metadata (QPI metadata are per page).
Do not use keyword arguments before variable positional arguments.
Make either all or none return statements in a function return expression.
@@ -67,323 +186,117 @@ Revisions
2018.11.6
Rename imsave function to imwrite.
Readd Python implementations of packints, delta, and bitorder codecs..
- Fix TiffFrame.compression AttributeError (bug fix).
+ Fix TiffFrame.compression AttributeError.
2018.10.18
- Rename tiffile package to tifffile.
-2018.10.10
- Pass 2710 tests.
- Read ZIF, the Zoomable Image Format (WIP).
- Decode YCbCr JPEG as RGB (tentative).
- Improve restoration of incomplete tiles.
- Allow to write grayscale with extrasamples without specifying planarconfig.
- Enable decoding of PNG and JXR via imagecodecs.
- Deprecate 32-bit platforms (too many memory errors during tests).
-2018.9.27
- Read Olympus SIS (WIP).
- Allow to write non-BigTIFF files up to ~4 GB (bug fix).
- Fix parsing date and time fields in SEM metadata (bug fix).
- Detect some circular IFD references.
- Enable WebP codecs via imagecodecs.
- Add option to read TiffSequence from ZIP containers.
- Remove TiffFile.isnative.
- Move TIFF struct format constants out of TiffFile namespace.
-2018.8.31
- Pass 2699 tests.
- Fix wrong TiffTag.valueoffset (bug fix).
- Towards reading Hamamatsu NDPI (WIP).
- Enable PackBits compression of byte and bool arrays.
- Fix parsing NULL terminated CZ_SEM strings.
-2018.8.24
- Move tifffile.py and related modules into tiffile package.
- Move usage examples to module docstring.
- Enable multi-threading for compressed tiles and pages by default.
- Add option to concurrently decode image tiles using threads.
- Do not skip empty tiles (bug fix).
- Read JPEG and J2K compressed strips and tiles.
- Allow floating point predictor on write.
- Add option to specify subfiletype on write.
- Depend on imagecodecs package instead of _tifffile, lzma, etc modules.
- Remove reverse_bitorder, unpack_ints, and decode functions.
- Use pytest instead of unittest.
-2018.6.20
- Save RGBA with unassociated extrasample by default (backward incompatible).
- Add option to specify ExtraSamples values.
-2018.6.17
- Pass 2680 tests.
- Towards reading JPEG and other compressions via imagecodecs package (WIP).
- Read SampleFormat VOID as UINT.
- Add function to validate TIFF using 'jhove -m TIFF-hul'.
- Save bool arrays as bilevel TIFF.
- Accept pathlib.Path as filenames.
- Move 'software' argument from TiffWriter __init__ to save.
- Raise DOS limit to 16 TB.
- Lazy load lzma and zstd compressors and decompressors.
- Add option to save IJMetadata tags.
- Return correct number of pages for truncated series (bug fix).
- Move EXIF tags to TIFF.TAG as per TIFF/EP standard.
-2018.2.18
- Pass 2293 tests.
- Always save RowsPerStrip and Resolution tags as required by TIFF standard.
- Do not use badly typed ImageDescription.
- Coherce bad ASCII string tags to bytes.
- Tuning of __str__ functions.
- Fix reading 'undefined' tag values (bug fix).
- Read and write ZSTD compressed data.
- Use hexdump to print byte strings.
- Determine TIFF byte order from data dtype in imsave.
- Add option to specify RowsPerStrip for compressed strips.
- Allow memory-map of arrays with non-native byte order.
- Attempt to handle ScanImage <= 5.1 files.
- Restore TiffPageSeries.pages sequence interface.
- Use numpy.frombuffer instead of fromstring to read from binary data.
- Parse GeoTIFF metadata.
- Add option to apply horizontal differencing before compression.
- Towards reading PerkinElmer QPI (QPTIFF, no test files).
- Do not index out of bounds data in tifffile.c unpackbits and decodelzw.
-2017.9.29 (tentative)
- Many backward incompatible changes improving speed and resource usage:
- Pass 2268 tests.
- Add detail argument to __str__ function. Remove info functions.
- Fix potential issue correcting offsets of large LSM files with positions.
- Remove TiffFile sequence interface; use TiffFile.pages instead.
- Do not make tag values available as TiffPage attributes.
- Use str (not bytes) type for tag and metadata strings (WIP).
- Use documented standard tag and value names (WIP).
- Use enums for some documented TIFF tag values.
- Remove 'memmap' and 'tmpfile' options; use out='memmap' instead.
- Add option to specify output in asarray functions.
- Add option to concurrently decode pages using threads.
- Add TiffPage.asrgb function (WIP).
- Do not apply colormap in asarray.
- Remove 'colormapped', 'rgbonly', and 'scale_mdgel' options from asarray.
- Consolidate metadata in TiffFile _metadata functions.
- Remove non-tag metadata properties from TiffPage.
- Add function to convert LSM to tiled BIN files.
- Align image data in file.
- Make TiffPage.dtype a numpy.dtype.
- Add 'ndim' and 'size' properties to TiffPage and TiffPageSeries.
- Allow imsave to write non-BigTIFF files up to ~4 GB.
- Only read one page for shaped series if possible.
- Add memmap function to create memory-mapped array stored in TIFF file.
- Add option to save empty arrays to TIFF files.
- Add option to save truncated TIFF files.
- Allow single tile images to be saved contiguously.
- Add optional movie mode for files with uniform pages.
- Lazy load pages.
- Use lightweight TiffFrame for IFDs sharing properties with key TiffPage.
- Move module constants to 'TIFF' namespace (speed up module import).
- Remove 'fastij' option from TiffFile.
- Remove 'pages' parameter from TiffFile.
- Remove TIFFfile alias.
- Deprecate Python 2.
- Require enum34 and futures packages on Python 2.7.
- Remove Record class and return all metadata as dict instead.
- Add functions to parse STK, MetaSeries, ScanImage, SVS, Pilatus metadata.
- Read tags from EXIF and GPS IFDs.
- Use pformat for tag and metadata values.
- Fix reading some UIC tags (bug fix).
- Do not modify input array in imshow (bug fix).
- Fix Python implementation of unpack_ints.
-2017.5.23
- Pass 1961 tests.
- Write correct number of SampleFormat values (bug fix).
- Use Adobe deflate code to write ZIP compressed files.
- Add option to pass tag values as packed binary data for writing.
- Defer tag validation to attribute access.
- Use property instead of lazyattr decorator for simple expressions.
-2017.3.17
- Write IFDs and tag values on word boundaries.
- Read ScanImage metadata.
- Remove is_rgb and is_indexed attributes from TiffFile.
- Create files used by doctests.
-2017.1.12
- Read Zeiss SEM metadata.
- Read OME-TIFF with invalid references to external files.
- Rewrite C LZW decoder (5x faster).
- Read corrupted LSM files missing EOI code in LZW stream.
-2017.1.1
- Add option to append images to existing TIFF files.
- Read files without pages.
- Read S-FEG and Helios NanoLab tags created by FEI software.
- Allow saving Color Filter Array (CFA) images.
- Add info functions returning more information about TiffFile and TiffPage.
- Add option to read specific pages only.
- Remove maxpages argument (backward incompatible).
- Remove test_tifffile function.
-2016.10.28
- Pass 1944 tests.
- Improve detection of ImageJ hyperstacks.
- Read TVIPS metadata created by EM-MENU (by Marco Oster).
- Add option to disable using OME-XML metadata.
- Allow non-integer range attributes in modulo tags (by Stuart Berg).
-2016.6.21
- Do not always memmap contiguous data in page series.
-2016.5.13
- Add option to specify resolution unit.
- Write grayscale images with extra samples when planarconfig is specified.
- Do not write RGB color images with 2 samples.
- Reorder TiffWriter.save keyword arguments (backward incompatible).
-2016.4.18
- Pass 1932 tests.
- TiffWriter, imread, and imsave accept open binary file streams.
-2016.04.13
- Correctly handle reversed fill order in 2 and 4 bps images (bug fix)..
- Implement reverse_bitorder in C.
-2016.03.18
- Fix saving additional ImageJ metadata.
-2016.2.22
- Pass 1920 tests.
- Write 8 bytes double tag values using offset if necessary (bug fix).
- Add option to disable writing second image description tag.
- Detect tags with incorrect counts.
- Disable color mapping for LSM.
-2015.11.13
- Read LSM 6 mosaics.
- Add option to specify directory of memory-mapped files.
- Add command line options to specify vmin and vmax values for colormapping.
-2015.10.06
- New helper function to apply colormaps.
- Renamed is_palette attributes to is_indexed (backward incompatible).
- Color-mapped samples are now contiguous (backward incompatible).
- Do not color-map ImageJ hyperstacks (backward incompatible).
- Towards reading Leica SCN.
-2015.9.25
- Read images with reversed bit order (FillOrder is LSB2MSB).
-2015.9.21
- Read RGB OME-TIFF.
- Warn about malformed OME-XML.
-2015.9.16
- Detect some corrupted ImageJ metadata.
- Better axes labels for 'shaped' files.
- Do not create TiffTag for default values.
- Chroma subsampling is not supported.
- Memory-map data in TiffPageSeries if possible (optional).
-2015.8.17
- Pass 1906 tests.
- Write ImageJ hyperstacks (optional).
- Read and write LZMA compressed data.
- Specify datetime when saving (optional).
- Save tiled and color-mapped images (optional).
- Ignore void bytecounts and offsets if possible.
- Ignore bogus image_depth tag created by ISS Vista software.
- Decode floating point horizontal differencing (not tiled).
- Save image data contiguously if possible.
- Only read first IFD from ImageJ files if possible.
- Read ImageJ 'raw' format (files larger than 4 GB).
- TiffPageSeries class for pages with compatible shape and data type.
- Try to read incomplete tiles.
- Open file dialog if no filename is passed on command line.
- Ignore errors when decoding OME-XML.
- Rename decoder functions (backward incompatible).
-2014.8.24
- TiffWriter class for incremental writing images.
- Simplify examples.
-2014.8.19
- Add memmap function to FileHandle.
- Add function to determine if image data in TiffPage is memory-mappable.
- Do not close files if multifile_close parameter is False.
-2014.8.10
- Pass 1730 tests.
- Return all extrasamples by default (backward incompatible).
- Read data from series of pages into memory-mapped array (optional).
- Squeeze OME dimensions (backward incompatible).
- Workaround missing EOI code in strips.
- Support image and tile depth tags (SGI extension).
- Better handling of STK/UIC tags (backward incompatible).
- Disable color mapping for STK.
- Julian to datetime converter.
- TIFF ASCII type may be NULL separated.
- Unwrap strip offsets for LSM files greater than 4 GB.
- Correct strip byte counts in compressed LSM files.
- Skip missing files in OME series.
- Read embedded TIFF files.
-2014.2.05
- Save rational numbers as type 5 (bug fix).
-2013.12.20
- Keep other files in OME multi-file series closed.
- FileHandle class to abstract binary file handle.
- Disable color mapping for bad OME-TIFF produced by bio-formats.
- Read bad OME-XML produced by ImageJ when cropping.
-2013.11.3
- Allow zlib compress data in imsave function (optional).
- Memory-map contiguous image data (optional).
-2013.10.28
- Read MicroManager metadata and little-endian ImageJ tag.
- Save extra tags in imsave function.
- Save tags in ascending order by code (bug fix).
-2012.10.18
- Accept file like objects (read from OIB files).
-2012.8.21
- Rename TIFFfile to TiffFile and TIFFpage to TiffPage.
- TiffSequence class for reading sequence of TIFF files.
- Read UltraQuant tags.
- Allow float numbers as resolution in imsave function.
-2012.8.3
- Read MD GEL tags and NIH Image header.
-2012.7.25
- Read ImageJ tags.
...
+Refer to the CHANGES file for older revisions.
+
Notes
-----
The API is not stable yet and might change between revisions.
Tested on little-endian platforms only.
-Python 2.7, 3.4, and 32-bit versions are deprecated.
+Python 32-bit versions are deprecated.
+
+Update pip and setuptools to the latest version before installing tifffile:
+
+ ``python -m pip install --upgrade pip setuptools``
+
+Tifffile relies on the `imagecodecs <https://pypi.org/project/imagecodecs/>`_
+package for encoding and decoding LZW, JPEG, and other compressed images..
+
+Several TIFF-like formats do not strictly adhere to the TIFF6 specification,
+some of which allow file or data sizes to exceed the 4 GB limit:
+
+* *BigTIFF* is identified by version number 43 and uses different file
+ header, IFD, and tag structures with 64-bit offsets. It adds more data types.
+ Tifffile can read and write BigTIFF files.
+* *ImageJ* hyperstacks store all image data, which may exceed 4 GB,
+ contiguously after the first IFD. Files > 4 GB contain one IFD only.
+ The size (shape and dtype) of the up to 6-dimensional image data can be
+ determined from the ImageDescription tag of the first IFD, which is Latin-1
+ encoded. Tifffile can read and write ImageJ hyperstacks.
+* *OME-TIFF* stores up to 8-dimensional data in one or multiple TIFF of BigTIFF
+ files. The 8-bit UTF-8 encoded OME-XML metadata found in the ImageDescription
+ tag of the first IFD defines the position of TIFF IFDs in the high
+ dimensional data. Tifffile can read OME-TIFF files, except when the OME-XML
+ metadata are stored in a separate file.
+* *LSM* stores all IFDs below 4 GB but wraps around 32-bit StripOffsets.
+ The StripOffsets of each series and position require separate unwrapping.
+ The StripByteCounts tag contains the number of bytes for the uncompressed
+ data. Tifffile can read large LSM files.
+* *NDPI* uses some 64-bit offsets in the file header, IFD, and tag structures.
+ Tag values/offsets can be corrected using high bits stored after IFD
+ structures. JPEG compressed tiles with dimensions > 65536 are not readable
+ with libjpeg. Tifffile can read NDPI files < 4 GB and decompress large JPEG
+ tiles using the imagecodecs library on Windows.
+* *ScanImage* optionally allows corrupt non-BigTIFF files > 2 GB. The values
+ of StripOffsets and StripByteCounts can be recovered using the constant
+ differences of the offsets of IFD and tag values throughout the file.
+ Tifffile can read such files on Python 3 if the image data are stored
+ contiguously in each page.
+* *GeoTIFF* sparse files allow strip or tile offsets and byte counts to be 0.
+ Such segments are implicitly set to 0 or the NODATA value on reading.
+ Tifffile can read GeoTIFF sparse files.
Other libraries for reading scientific TIFF files from Python:
-* `Python-bioformats <https://github.com/CellProfiler/python-bioformats>`_
-* `Imread <https://github.com/luispedro/imread>`_
-* `GDAL <https://github.com/OSGeo/gdal/tree/master/gdal/swig/python>`_
-* `OpenSlide-python <https://github.com/openslide/openslide-python>`_
-* `PyLibTiff <https://github.com/pearu/pylibtiff>`_
-* `SimpleITK <http://www.simpleitk.org>`_
-* `PyLSM <https://launchpad.net/pylsm>`_
-* `PyMca.TiffIO.py <https://github.com/vasole/pymca>`_ (same as fabio.TiffIO)
-* `BioImageXD.Readers <http://www.bioimagexd.net/>`_
-* `Cellcognition.io <http://cellcognition.org/>`_
-* `pymimage <https://github.com/ardoi/pymimage>`_
-* `pytiff <https://github.com/FZJ-INM1-BDA/pytiff>`_
-
-Acknowledgements
-----------------
-* Egor Zindy, University of Manchester, for lsm_scan_info specifics.
-* Wim Lewis for a bug fix and some LSM functions.
-* Hadrien Mary for help on reading MicroManager files.
-* Christian Kliche for help writing tiled and color-mapped files.
+* `Python-bioformats <https://github.com/CellProfiler/python-bioformats>`_
+* `Imread <https://github.com/luispedro/imread>`_
+* `GDAL <https://github.com/OSGeo/gdal/tree/master/gdal/swig/python>`_
+* `OpenSlide-python <https://github.com/openslide/openslide-python>`_
+* `PyLibTiff <https://github.com/pearu/pylibtiff>`_
+* `SimpleITK <https://github.com/SimpleITK/SimpleITK>`_
+* `PyLSM <https://launchpad.net/pylsm>`_
+* `PyMca.TiffIO.py <https://github.com/vasole/pymca>`_ (same as fabio.TiffIO)
+* `BioImageXD.Readers <http://www.bioimagexd.net/>`_
+* `CellCognition <https://cellcognition-project.org/>`_
+* `pymimage <https://github.com/ardoi/pymimage>`_
+* `pytiff <https://github.com/FZJ-INM1-BDA/pytiff>`_
+* `ScanImageTiffReaderPython
+ <https://gitlab.com/vidriotech/scanimagetiffreader-python>`_
+* `bigtiff <https://pypi.org/project/bigtiff>`_
+
+Some libraries are using tifffile to write OME-TIFF files:
+
+* `Zeiss Apeer OME-TIFF library
+ <https://github.com/apeer-micro/apeer-ometiff-library>`_
+* `Allen Institute for Cell Science imageio
+ <https://pypi.org/project/aicsimageio>`_
References
----------
-1) TIFF 6.0 Specification and Supplements. Adobe Systems Incorporated.
+1. TIFF 6.0 Specification and Supplements. Adobe Systems Incorporated.
https://www.adobe.io/open/standards/TIFF.html
-2) TIFF File Format FAQ. https://www.awaresystems.be/imaging/tiff/faq.html
-3) MetaMorph Stack (STK) Image File Format.
+2. TIFF File Format FAQ. https://www.awaresystems.be/imaging/tiff/faq.html
+3. MetaMorph Stack (STK) Image File Format.
http://mdc.custhelp.com/app/answers/detail/a_id/18862
-4) Image File Format Description LSM 5/7 Release 6.0 (ZEN 2010).
+4. Image File Format Description LSM 5/7 Release 6.0 (ZEN 2010).
Carl Zeiss MicroImaging GmbH. BioSciences. May 10, 2011
-5) The OME-TIFF format.
+5. The OME-TIFF format.
https://docs.openmicroscopy.org/ome-model/5.6.4/ome-tiff/
-6) UltraQuant(r) Version 6.0 for Windows Start-Up Guide.
+6. UltraQuant(r) Version 6.0 for Windows Start-Up Guide.
http://www.ultralum.com/images%20ultralum/pdf/UQStart%20Up%20Guide.pdf
-7) Micro-Manager File Formats.
+7. Micro-Manager File Formats.
https://micro-manager.org/wiki/Micro-Manager_File_Formats
-8) Tags for TIFF and Related Specifications. Digital Preservation.
+8. Tags for TIFF and Related Specifications. Digital Preservation.
https://www.loc.gov/preservation/digital/formats/content/tiff_tags.shtml
-9) ScanImage BigTiff Specification - ScanImage 2016.
+9. ScanImage BigTiff Specification - ScanImage 2016.
http://scanimage.vidriotechnologies.com/display/SI2016/
ScanImage+BigTiff+Specification
-10) CIPA DC-008-2016: Exchangeable image file format for digital still cameras:
+10. CIPA DC-008-2016: Exchangeable image file format for digital still cameras:
Exif Version 2.31.
http://www.cipa.jp/std/documents/e/DC-008-Translation-2016-E.pdf
-11) ZIF, the Zoomable Image File format. http://zif.photo/
+11. ZIF, the Zoomable Image File format. http://zif.photo/
+12. GeoTIFF File Format https://gdal.org/drivers/raster/gtiff.html
Examples
--------
Save a 3D numpy array to a multi-page, 16-bit grayscale TIFF file:
->>> data = numpy.random.randint(0, 2**16, (4, 301, 219), 'uint16')
+>>> data = numpy.random.randint(0, 2**12, (4, 301, 219), 'uint16')
>>> imwrite('temp.tif', data, photometric='minisblack')
Read the whole image stack from the TIFF file as numpy array:
@@ -394,7 +307,7 @@ Read the whole image stack from the TIFF file as numpy array:
>>> image_stack.dtype
dtype('uint16')
-Read the image from first page (IFD) in the TIFF file:
+Read the image from the first page in the TIFF file as numpy array:
>>> image = imread('temp.tif', key=0)
>>> image.shape
@@ -416,14 +329,36 @@ Save a floating-point array and metadata, using zlib compression:
>>> data = numpy.random.rand(2, 5, 3, 301, 219).astype('float32')
>>> imwrite('temp.tif', data, compress=6, metadata={'axes': 'TZCYX'})
-Save a volume with xyz voxel size 2.6755x2.6755x3.9474 µm^3 to ImageJ file:
+Save a volume with xyz voxel size 2.6755x2.6755x3.9474 micron^3 to an ImageJ
+formatted TIFF file:
>>> volume = numpy.random.randn(57*256*256).astype('float32')
>>> volume.shape = 1, 57, 1, 256, 256, 1 # dimensions in TZCYXS order
>>> imwrite('temp.tif', volume, imagej=True, resolution=(1./2.6755, 1./2.6755),
... metadata={'spacing': 3.947368, 'unit': 'um'})
-Read hyperstack and metadata from ImageJ file:
+Get the shape and dtype of the volume stored in the TIFF file:
+
+>>> tif = TiffFile('temp.tif')
+>>> len(tif.pages) # number of pages in the file
+57
+>>> page = tif.pages[0] # get shape and dtype of the image in the first page
+>>> page.shape
+(256, 256)
+>>> page.dtype
+dtype('float32')
+>>> page.axes
+'YX'
+>>> series = tif.series[0] # get shape and dtype of the first image series
+>>> series.shape
+(57, 256, 256)
+>>> series.dtype
+dtype('float32')
+>>> series.axes
+'ZYX'
+>>> tif.close()
+
+Read hyperstack and metadata from the ImageJ file:
>>> with TiffFile('temp.tif') as tif:
... imagej_hyperstack = tif.asarray()
@@ -433,35 +368,58 @@ Read hyperstack and metadata from ImageJ file:
>>> imagej_metadata['slices']
57
+Read the "XResolution" tag from the first page in the TIFF file:
+
+>>> with TiffFile('temp.tif') as tif:
+... tag = tif.pages[0].tags['XResolution']
+>>> tag.value
+(2000, 5351)
+>>> tag.name
+'XResolution'
+>>> tag.code
+282
+>>> tag.count
+1
+>>> tag.dtype
+'2I'
+
+Read images from a selected range of pages:
+
+>>> image = imread('temp.tif', key=range(4, 40, 2))
+>>> image.shape
+(18, 256, 256)
+
Create an empty TIFF file and write to the memory-mapped numpy array:
>>> memmap_image = memmap('temp.tif', shape=(256, 256), dtype='float32')
>>> memmap_image[255, 255] = 1.0
>>> memmap_image.flush()
->>> memmap_image.shape, memmap_image.dtype
-((256, 256), dtype('float32'))
>>> del memmap_image
-Memory-map image data in the TIFF file:
+Memory-map image data of the first page in the TIFF file:
>>> memmap_image = memmap('temp.tif', page=0)
>>> memmap_image[255, 255]
1.0
>>> del memmap_image
-Successively append images to a BigTIFF file:
+Successively append images to a BigTIFF file, which can exceed 4 GB:
>>> data = numpy.random.randint(0, 255, (5, 2, 3, 301, 219), 'uint8')
>>> with TiffWriter('temp.tif', bigtiff=True) as tif:
... for i in range(data.shape[0]):
... tif.save(data[i], compress=6, photometric='minisblack')
+Append an image to the existing TIFF file:
+
+>>> data = numpy.random.randint(0, 255, (301, 219, 3), 'uint8')
+>>> imwrite('temp.tif', data, append=True)
+
Iterate over pages and tags in the TIFF file and successively read images:
>>> with TiffFile('temp.tif') as tif:
-... image_stack = tif.asarray()
... for page in tif.pages:
-... for tag in page.tags.values():
+... for tag in page.tags:
... tag_name, tag_value = tag.name, tag.value
... image = page.asarray()
@@ -471,7 +429,7 @@ Save two image series to a TIFF file:
>>> data1 = numpy.random.randint(0, 255, (5, 301, 219), 'uint16')
>>> with TiffWriter('temp.tif') as tif:
... tif.save(data0, compress=6, photometric='rgb')
-... tif.save(data1, compress=6, photometric='minisblack')
+... tif.save(data1, compress=6, photometric='minisblack', contiguous=False)
Read the second image series from the TIFF file:
@@ -479,7 +437,7 @@ Read the second image series from the TIFF file:
>>> series1.shape
(5, 301, 219)
-Read an image stack from a sequence of TIFF files with a file name pattern:
+Read an image stack from a series of TIFF files with a file name pattern:
>>> imwrite('temp_C001T001.tif', numpy.random.rand(64, 64))
>>> imwrite('temp_C001T002.tif', numpy.random.rand(64, 64))
@@ -491,3 +449,10 @@ Read an image stack from a sequence of TIFF files with a file name pattern:
>>> data = image_sequence.asarray()
>>> data.shape
(1, 2, 64, 64)
+
+Create a TIFF file from an iterator of tiles:
+
+>>> def tiles():
+... data = numpy.arange(3*4*16*16, dtype='uint16').reshape((3*4, 16, 16))
+... for i in range(data.shape[0]): yield data[i]
+>>> imwrite('temp.tif', tiles(), dtype='uint16', shape=(48, 64), tile=(16, 16))
=====================================
setup.py
=====================================
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
# tifffile/setup.py
"""Tifffile package setuptools script."""
@@ -10,29 +9,47 @@ from setuptools import setup
buildnumber = ''
-imagecodecs = 'imagecodecs>=2018.11.8'
-
with open('tifffile/tifffile.py') as fh:
code = fh.read()
version = re.search(r"__version__ = '(.*?)'", code).groups()[0]
version += ('.' + buildnumber) if buildnumber else ''
-description = re.search(r'"""(.*)\.[\r\n?|\n]', code).groups()[0]
-readme = re.search(r'[\r\n?|\n]{2}"""(.*)"""[\r\n?|\n]{2}from', code,
- re.MULTILINE | re.DOTALL).groups()[0]
-license = re.search(r'(# Copyright.*?[\r\n?|\n])[\r\n?|\n]+""', code,
- re.MULTILINE | re.DOTALL).groups()[0]
-readme = '\n'.join([description, '=' * len(description)]
- + readme.splitlines()[1:])
-license = license.replace('# ', '').replace('#', '')
+description = re.search(r'"""(.*)\.(?:\r\n|\r|\n)', code).groups()[0]
+
+readme = re.search(r'(?:\r\n|\r|\n){2}"""(.*)"""(?:\r\n|\r|\n){2}__version__',
+ code, re.MULTILINE | re.DOTALL).groups()[0]
+
+readme = '\n'.join([description, '=' * len(description)] +
+ readme.splitlines()[1:])
if 'sdist' in sys.argv:
- with open('LICENSE', 'w') as fh:
- fh.write(license)
+ # update README, LICENSE, and CHANGES files
+
with open('README.rst', 'w') as fh:
fh.write(readme)
+ license = re.search(r'(# Copyright.*?(?:\r\n|\r|\n))(?:\r\n|\r|\n)+""',
+ code, re.MULTILINE | re.DOTALL).groups()[0]
+
+ license = license.replace('# ', '').replace('#', '')
+
+ with open('LICENSE', 'w') as fh:
+ fh.write('BSD 3-Clause License\n\n')
+ fh.write(license)
+
+ revisions = re.search(r'(?:\r\n|\r|\n){2}(Revisions.*) \.\.\.', readme,
+ re.MULTILINE | re.DOTALL).groups()[0].strip()
+
+ with open('CHANGES.rst', 'r') as fh:
+ old = fh.read()
+
+ d = revisions.splitlines()[-1]
+ old = old.split(d)[-1]
+ with open('CHANGES.rst', 'w') as fh:
+ fh.write(revisions.strip())
+ fh.write(old)
+
setup(
name='tifffile',
version=version,
@@ -43,24 +60,24 @@ setup(
url='https://www.lfd.uci.edu/~gohlke/',
license='BSD',
packages=['tifffile'],
- python_requires='>=2.7',
+ python_requires='>=3.6',
install_requires=[
- 'numpy>=1.11.3',
- 'pathlib;python_version=="2.7"',
- 'enum34;python_version=="2.7"',
- 'futures;python_version=="2.7"',
- # require imagecodecs on Windows only
- imagecodecs + ';platform_system=="Windows"',
- ],
+ 'numpy>=1.15.1',
+ 'imagecodecs>=2020.2.18',
+ ],
extras_require={
- 'all': ['matplotlib>=2.2', imagecodecs],
+ 'all': ['matplotlib>=3.1'],
},
- tests_require=['pytest', imagecodecs],
+ tests_require=[
+ 'pytest', 'czifile', 'cmapfile', 'oiffile', 'lfdfiles', 'roifile'
+ ],
entry_points={
'console_scripts': [
'tifffile = tifffile:main',
- 'lsm2bin = tifffile.lsm2bin:main'
- ]},
+ 'lsm2bin = tifffile.lsm2bin:main',
+ ],
+ # 'napari.plugin': ['tifffile = tifffile.napari_tifffile'],
+ },
platforms=['any'],
classifiers=[
'Development Status :: 4 - Beta',
@@ -68,12 +85,9 @@ setup(
'Intended Audience :: Science/Research',
'Intended Audience :: Developers',
'Operating System :: OS Independent',
- 'Programming Language :: Python :: 2',
- 'Programming Language :: Python :: 2.7',
- 'Programming Language :: Python :: 3',
- 'Programming Language :: Python :: 3.4',
- 'Programming Language :: Python :: 3.5',
+ 'Programming Language :: Python :: 3 :: Only',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
- ],
+ 'Programming Language :: Python :: 3.8',
+ ],
)
=====================================
setup_tiffile.py deleted
=====================================
@@ -1,41 +0,0 @@
-# -*- coding: utf-8 -*-
-# setup_tiffile.py
-
-"""Tiffile module setuptools script."""
-
-import re
-
-from setuptools import setup
-
-with open('tifffile/tifffile.py') as fh:
- code = fh.read()
-
-version = re.search(r"__version__ = '(.*?)'", code).groups()[0]
-
-setup(
- name='tiffile',
- version=version,
- description='The tiffile package is deprecated. '
- 'Please use the tifffile package instead.',
- author='Christoph Gohlke',
- author_email='cgohlke at uci.edu',
- url='https://www.lfd.uci.edu/~gohlke/',
- license='BSD',
- py_modules=['tiffile'],
- install_requires=['tifffile'],
- platforms=['any'],
- classifiers=[
- 'Development Status :: 4 - Beta',
- 'License :: OSI Approved :: BSD License',
- 'Intended Audience :: Science/Research',
- 'Intended Audience :: Developers',
- 'Operating System :: OS Independent',
- 'Programming Language :: Python :: 2',
- 'Programming Language :: Python :: 2.7',
- 'Programming Language :: Python :: 3',
- 'Programming Language :: Python :: 3.4',
- 'Programming Language :: Python :: 3.5',
- 'Programming Language :: Python :: 3.6',
- 'Programming Language :: Python :: 3.7',
- ],
-)
=====================================
tests/conftest.py
=====================================
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
# tifffile/tests/conftest.py
collect_ignore = ['_tmp', 'data']
@@ -6,10 +5,14 @@ collect_ignore = ['_tmp', 'data']
def pytest_report_header(config):
try:
- import numpy
- import tifffile
- import imagecodecs
- return 'versions: tifffile-%s, imagecodecs-%s, numpy-%s' % (
- tifffile.__version__, imagecodecs.__version__, numpy.__version__)
+ from numpy import __version__ as numpy
+ from tifffile import __version__ as tifffile
+ from test_tifffile import config
+ try:
+ from imagecodecs import __version__ as imagecodecs
+ except ImportError:
+ imagecodecs = 'N/A'
+ return ('versions: tifffile-%s, imagecodecs-%s, numpy-%s\n'
+ 'test config: %s' % (tifffile, imagecodecs, numpy, config()))
except Exception:
pass
=====================================
tests/test_tifffile.py
=====================================
The diff for this file was not included because it is too large.
=====================================
tifffile.egg-info/PKG-INFO
=====================================
@@ -1,6 +1,6 @@
Metadata-Version: 2.1
Name: tifffile
-Version: 2018.11.28
+Version: 2020.5.11
Summary: Read and write TIFF(r) files
Home-page: https://www.lfd.uci.edu/~gohlke/
Author: Christoph Gohlke
@@ -12,29 +12,29 @@ Description: Read and write TIFF(r) files
Tifffile is a Python library to
(1) store numpy arrays in TIFF (Tagged Image File Format) files, and
- (2) read image and metadata from TIFF like files used in bioimaging.
+ (2) read image and metadata from TIFF-like files used in bioimaging.
- Image and metadata can be read from TIFF, BigTIFF, OME-TIFF, STK, LSM, NIH,
- SGI, ImageJ, MicroManager, FluoView, ScanImage, SEQ, GEL, SVS, SCN, SIS, ZIF,
- QPI, and GeoTIFF files.
+ Image and metadata can be read from TIFF, BigTIFF, OME-TIFF, STK, LSM, SGI,
+ NIHImage, ImageJ, MicroManager, FluoView, ScanImage, SEQ, GEL, SVS, SCN, SIS,
+ ZIF, QPTIFF, NDPI, and GeoTIFF files.
Numpy arrays can be written to TIFF, BigTIFF, and ImageJ hyperstack compatible
files in multi-page, memory-mappable, tiled, predicted, or compressed form.
- Only a subset of the TIFF specification is supported, mainly uncompressed and
- losslessly compressed 1, 8, 16, 32 and 64-bit integer, 16, 32 and 64-bit float,
- grayscale and RGB(A) images.
+ A subset of the TIFF specification is supported, mainly uncompressed and
+ losslessly compressed 8, 16, 32 and 64-bit integer, 16, 32 and 64-bit float,
+ grayscale and multi-sample images.
Specifically, reading slices of image data, CCITT and OJPEG compression,
- chroma subsampling without JPEG compression, or IPTC and XMP metadata are not
- implemented.
+ chroma subsampling without JPEG compression, color space transformations,
+ samples with differing types, or IPTC and XMP metadata are not implemented.
TIFF(r), the Tagged Image File Format, is a trademark and under control of
- Adobe Systems Incorporated. BigTIFF allows for files greater than 4 GB.
- STK, LSM, FluoView, SGI, SEQ, GEL, and OME-TIFF, are custom extensions
- defined by Molecular Devices (Universal Imaging Corporation), Carl Zeiss
- MicroImaging, Olympus, Silicon Graphics International, Media Cybernetics,
- Molecular Dynamics, and the Open Microscopy Environment consortium
- respectively.
+ Adobe Systems Incorporated. BigTIFF allows for files larger than 4 GB.
+ STK, LSM, FluoView, SGI, SEQ, GEL, QPTIFF, NDPI, and OME-TIFF, are custom
+ extensions defined by Molecular Devices (Universal Imaging Corporation),
+ Carl Zeiss MicroImaging, Olympus, Silicon Graphics International,
+ Media Cybernetics, Molecular Dynamics, PerkinElmer, Hamamatsu, and the
+ Open Microscopy Environment consortium respectively.
For command line usage run ``python -m tifffile --help``
@@ -44,29 +44,148 @@ Description: Read and write TIFF(r) files
:Organization:
Laboratory for Fluorescence Dynamics, University of California, Irvine
- :Version: 2018.11.28
+ :License: BSD 3-Clause
+
+ :Version: 2020.5.11
Requirements
------------
- * `CPython 2.7 or 3.5+ 64-bit <https://www.python.org>`_
- * `Numpy 1.14 <https://www.numpy.org>`_
- * `Imagecodecs 2018.11.8 <https://pypi.org/project/imagecodecs/>`_
- (optional; used for decoding LZW, JPEG, etc.)
- * `Matplotlib 2.2 <https://www.matplotlib.org>`_ (optional; used for plotting)
- * Python 2.7 requires 'futures', 'enum34', and 'pathlib'.
+ This release has been tested with the following requirements and dependencies
+ (other versions may work):
+
+ * `CPython 3.6.8, 3.7.7, 3.8.2 64-bit <https://www.python.org>`_
+ * `Numpy 1.16.6 <https://www.numpy.org>`_
+ * `Imagecodecs 2020.2.18 <https://pypi.org/project/imagecodecs/>`_
+ (required only for encoding or decoding LZW, JPEG, etc.)
+ * `Matplotlib 3.1 <https://www.matplotlib.org>`_ (required only for plotting)
Revisions
---------
+ 2020.5.11
+ Pass 2908 tests.
+ Fix reading ImageJ grayscale mode RGB images (#6).
+ Remove napari reader plugin.
+ 2020.5.7
+ Add napari reader plugin (tentative).
+ Fix writing single tiles larger than image data (#3).
+ Always store ExtraSamples values in tuple (breaking).
+ 2020.5.5
+ Allow to write tiled TIFF from iterator of tiles (WIP).
+ Add function to iterate over decoded segments of TiffPage (WIP).
+ Pass chunks of segments to ThreadPoolExecutor.map to reduce memory usage.
+ Fix reading invalid files with too many strips.
+ Fix writing over-aligned image data.
+ Detect OME-XML without declaration (#2).
+ Support LERC compression (WIP).
+ Delay load imagecodecs functions.
+ Remove maxsize parameter from asarray (breaking).
+ Deprecate ijmetadata parameter from TiffWriter.save (use metadata).
+ 2020.2.16
+ Add function to decode individual strips or tiles.
+ Read strips and tiles in order of their offsets.
+ Enable multi-threading when decompressing multiple strips.
+ Replace TiffPage.tags dictionary with TiffTags (breaking).
+ Replace TIFF.TAGS dictionary with TiffTagRegistry.
+ Remove TIFF.TAG_NAMES (breaking).
+ Improve handling of TiffSequence parameters in imread.
+ Match last uncommon parts of file paths to FileSequence pattern (breaking).
+ Allow letters in FileSequence pattern for indexing well plate rows.
+ Allow to reorder axes in FileSequence.
+ Allow to write > 4 GB arrays to plain TIFF when using compression.
+ Allow to write zero size numpy arrays to nonconformant TIFF (tentative).
+ Fix xml2dict.
+ Require imagecodecs >= 2020.1.31.
+ Remove support for imagecodecs-lite (breaking).
+ Remove verify parameter to asarray function (breaking).
+ Remove deprecated lzw_decode functions (breaking).
+ Remove support for Python 2.7 and 3.5 (breaking).
+ 2019.7.26
+ Fix infinite loop reading more than two tags of same code in IFD.
+ Delay import of logging module.
+ 2019.7.20
+ Fix OME-XML detection for files created by Imaris.
+ Remove or replace assert statements.
+ 2019.7.2
+ Do not write SampleFormat tag for unsigned data types.
+ Write ByteCount tag values as SHORT or LONG if possible.
+ Allow to specify axes in FileSequence pattern via group names.
+ Add option to concurrently read FileSequence using threads.
+ Derive TiffSequence from FileSequence.
+ Use str(datetime.timedelta) to format Timer duration.
+ Use perf_counter for Timer if possible.
+ 2019.6.18
+ Fix reading planar RGB ImageJ files created by Bio-Formats.
+ Fix reading single-file, multi-image OME-TIFF without UUID.
+ Presume LSM stores uncompressed images contiguously per page..
+ Reformat some complex expressions.
+ 2019.5.30
+ Ignore invalid frames in OME-TIFF.
+ Set default subsampling to (2, 2) for RGB JPEG compression.
+ Fix reading and writing planar RGB JPEG compression.
+ Replace buffered_read with FileHandle.read_segments.
+ Include page or frame numbers in exceptions and warnings.
+ Add Timer class.
+ 2019.5.22
+ Add optional chroma subsampling for JPEG compression.
+ Enable writing PNG, JPEG, JPEGXR, and JPEG2K compression (WIP).
+ Fix writing tiled images with WebP compression.
+ Improve handling GeoTIFF sparse files.
+ 2019.3.18
+ Fix regression decoding JPEG with RGB photometrics.
+ Fix reading OME-TIFF files with corrupted but unused pages.
+ Allow to load TiffFrame without specifying keyframe.
+ Calculate virtual TiffFrames for non-BigTIFF ScanImage files > 2GB.
+ Rename property is_chroma_subsampled to is_subsampled (breaking).
+ Make more attributes and methods private (WIP).
+ 2019.3.8
+ Fix MemoryError when RowsPerStrip > ImageLength.
+ Fix SyntaxWarning on Python 3.8.
+ Fail to decode JPEG to planar RGB (tentative).
+ Separate public from private test files (WIP).
+ Allow testing without data files or imagecodecs.
+ 2019.2.22
+ Use imagecodecs-lite as a fallback for imagecodecs.
+ Simplify reading numpy arrays from file.
+ Use TiffFrames when reading arrays from page sequences.
+ Support slices and iterators in TiffPageSeries sequence interface.
+ Auto-detect uniform series.
+ Use page hash to determine generic series.
+ Turn off TiffPages cache (tentative).
+ Pass through more parameters in imread.
+ Discontinue movie parameter in imread and TiffFile (breaking).
+ Discontinue bigsize parameter in imwrite (breaking).
+ Raise TiffFileError in case of issues with TIFF structure.
+ Return TiffFile.ome_metadata as XML (breaking).
+ Ignore OME series when last dimensions are not stored in TIFF pages.
+ 2019.2.10
+ Assemble IFDs in memory to speed-up writing on some slow media.
+ Handle discontinued arguments fastij, multifile_close, and pages.
+ 2019.1.30
+ Use black background in imshow.
+ Do not write datetime tag by default (breaking).
+ Fix OME-TIFF with SamplesPerPixel > 1.
+ Allow 64-bit IFD offsets for NDPI (files > 4GB still not supported).
+ 2019.1.4
+ Fix decoding deflate without imagecodecs.
+ 2019.1.1
+ Update copyright year.
+ Require imagecodecs >= 2018.12.16.
+ Do not use JPEG tables from keyframe.
+ Enable decoding large JPEG in NDPI.
+ Decode some old-style JPEG.
+ Reorder OME channel axis to match PlanarConfiguration storage.
+ Return tiled images as contiguous arrays.
+ Add decode_lzw proxy function for compatibility with old czifile module.
+ Use dedicated logger.
2018.11.28
- Pass 2739 tests.
Make SubIFDs accessible as TiffPage.pages.
- Make parsing of TiffSequence axes pattern optional (backward incompatible).
+ Make parsing of TiffSequence axes pattern optional (breaking).
Limit parsing of TiffSequence axes pattern to file names, not path names.
Do not interpolate in imshow if image dimensions <= 512, else use bilinear.
Use logging.warning instead of warnings.warn in many cases.
Fix numpy FutureWarning for out == 'memmap'.
Adjust ZSTD and WebP compression to libtiff-4.0.10 (WIP).
- Decode old style LZW with imagecodecs >= 2018.11.8.
+ Decode old-style LZW with imagecodecs >= 2018.11.8.
Remove TiffFile.qptiff_metadata (QPI metadata are per page).
Do not use keyword arguments before variable positional arguments.
Make either all or none return statements in a function return expression.
@@ -75,323 +194,117 @@ Description: Read and write TIFF(r) files
2018.11.6
Rename imsave function to imwrite.
Readd Python implementations of packints, delta, and bitorder codecs.
- Fix TiffFrame.compression AttributeError (bug fix).
+ Fix TiffFrame.compression AttributeError.
2018.10.18
- Rename tiffile package to tifffile.
- 2018.10.10
- Pass 2710 tests.
- Read ZIF, the Zoomable Image Format (WIP).
- Decode YCbCr JPEG as RGB (tentative).
- Improve restoration of incomplete tiles.
- Allow to write grayscale with extrasamples without specifying planarconfig.
- Enable decoding of PNG and JXR via imagecodecs.
- Deprecate 32-bit platforms (too many memory errors during tests).
- 2018.9.27
- Read Olympus SIS (WIP).
- Allow to write non-BigTIFF files up to ~4 GB (bug fix).
- Fix parsing date and time fields in SEM metadata (bug fix).
- Detect some circular IFD references.
- Enable WebP codecs via imagecodecs.
- Add option to read TiffSequence from ZIP containers.
- Remove TiffFile.isnative.
- Move TIFF struct format constants out of TiffFile namespace.
- 2018.8.31
- Pass 2699 tests.
- Fix wrong TiffTag.valueoffset (bug fix).
- Towards reading Hamamatsu NDPI (WIP).
- Enable PackBits compression of byte and bool arrays.
- Fix parsing NULL terminated CZ_SEM strings.
- 2018.8.24
- Move tifffile.py and related modules into tiffile package.
- Move usage examples to module docstring.
- Enable multi-threading for compressed tiles and pages by default.
- Add option to concurrently decode image tiles using threads.
- Do not skip empty tiles (bug fix).
- Read JPEG and J2K compressed strips and tiles.
- Allow floating point predictor on write.
- Add option to specify subfiletype on write.
- Depend on imagecodecs package instead of _tifffile, lzma, etc modules.
- Remove reverse_bitorder, unpack_ints, and decode functions.
- Use pytest instead of unittest.
- 2018.6.20
- Save RGBA with unassociated extrasample by default (backward incompatible).
- Add option to specify ExtraSamples values.
- 2018.6.17
- Pass 2680 tests.
- Towards reading JPEG and other compressions via imagecodecs package (WIP).
- Read SampleFormat VOID as UINT.
- Add function to validate TIFF using 'jhove -m TIFF-hul'.
- Save bool arrays as bilevel TIFF.
- Accept pathlib.Path as filenames.
- Move 'software' argument from TiffWriter __init__ to save.
- Raise DOS limit to 16 TB.
- Lazy load lzma and zstd compressors and decompressors.
- Add option to save IJMetadata tags.
- Return correct number of pages for truncated series (bug fix).
- Move EXIF tags to TIFF.TAG as per TIFF/EP standard.
- 2018.2.18
- Pass 2293 tests.
- Always save RowsPerStrip and Resolution tags as required by TIFF standard.
- Do not use badly typed ImageDescription.
- Coherce bad ASCII string tags to bytes.
- Tuning of __str__ functions.
- Fix reading 'undefined' tag values (bug fix).
- Read and write ZSTD compressed data.
- Use hexdump to print byte strings.
- Determine TIFF byte order from data dtype in imsave.
- Add option to specify RowsPerStrip for compressed strips.
- Allow memory-map of arrays with non-native byte order.
- Attempt to handle ScanImage <= 5.1 files.
- Restore TiffPageSeries.pages sequence interface.
- Use numpy.frombuffer instead of fromstring to read from binary data.
- Parse GeoTIFF metadata.
- Add option to apply horizontal differencing before compression.
- Towards reading PerkinElmer QPI (QPTIFF, no test files).
- Do not index out of bounds data in tifffile.c unpackbits and decodelzw.
- 2017.9.29 (tentative)
- Many backward incompatible changes improving speed and resource usage:
- Pass 2268 tests.
- Add detail argument to __str__ function. Remove info functions.
- Fix potential issue correcting offsets of large LSM files with positions.
- Remove TiffFile sequence interface; use TiffFile.pages instead.
- Do not make tag values available as TiffPage attributes.
- Use str (not bytes) type for tag and metadata strings (WIP).
- Use documented standard tag and value names (WIP).
- Use enums for some documented TIFF tag values.
- Remove 'memmap' and 'tmpfile' options; use out='memmap' instead.
- Add option to specify output in asarray functions.
- Add option to concurrently decode pages using threads.
- Add TiffPage.asrgb function (WIP).
- Do not apply colormap in asarray.
- Remove 'colormapped', 'rgbonly', and 'scale_mdgel' options from asarray.
- Consolidate metadata in TiffFile _metadata functions.
- Remove non-tag metadata properties from TiffPage.
- Add function to convert LSM to tiled BIN files.
- Align image data in file.
- Make TiffPage.dtype a numpy.dtype.
- Add 'ndim' and 'size' properties to TiffPage and TiffPageSeries.
- Allow imsave to write non-BigTIFF files up to ~4 GB.
- Only read one page for shaped series if possible.
- Add memmap function to create memory-mapped array stored in TIFF file.
- Add option to save empty arrays to TIFF files.
- Add option to save truncated TIFF files.
- Allow single tile images to be saved contiguously.
- Add optional movie mode for files with uniform pages.
- Lazy load pages.
- Use lightweight TiffFrame for IFDs sharing properties with key TiffPage.
- Move module constants to 'TIFF' namespace (speed up module import).
- Remove 'fastij' option from TiffFile.
- Remove 'pages' parameter from TiffFile.
- Remove TIFFfile alias.
- Deprecate Python 2.
- Require enum34 and futures packages on Python 2.7.
- Remove Record class and return all metadata as dict instead.
- Add functions to parse STK, MetaSeries, ScanImage, SVS, Pilatus metadata.
- Read tags from EXIF and GPS IFDs.
- Use pformat for tag and metadata values.
- Fix reading some UIC tags (bug fix).
- Do not modify input array in imshow (bug fix).
- Fix Python implementation of unpack_ints.
- 2017.5.23
- Pass 1961 tests.
- Write correct number of SampleFormat values (bug fix).
- Use Adobe deflate code to write ZIP compressed files.
- Add option to pass tag values as packed binary data for writing.
- Defer tag validation to attribute access.
- Use property instead of lazyattr decorator for simple expressions.
- 2017.3.17
- Write IFDs and tag values on word boundaries.
- Read ScanImage metadata.
- Remove is_rgb and is_indexed attributes from TiffFile.
- Create files used by doctests.
- 2017.1.12
- Read Zeiss SEM metadata.
- Read OME-TIFF with invalid references to external files.
- Rewrite C LZW decoder (5x faster).
- Read corrupted LSM files missing EOI code in LZW stream.
- 2017.1.1
- Add option to append images to existing TIFF files.
- Read files without pages.
- Read S-FEG and Helios NanoLab tags created by FEI software.
- Allow saving Color Filter Array (CFA) images.
- Add info functions returning more information about TiffFile and TiffPage.
- Add option to read specific pages only.
- Remove maxpages argument (backward incompatible).
- Remove test_tifffile function.
- 2016.10.28
- Pass 1944 tests.
- Improve detection of ImageJ hyperstacks.
- Read TVIPS metadata created by EM-MENU (by Marco Oster).
- Add option to disable using OME-XML metadata.
- Allow non-integer range attributes in modulo tags (by Stuart Berg).
- 2016.6.21
- Do not always memmap contiguous data in page series.
- 2016.5.13
- Add option to specify resolution unit.
- Write grayscale images with extra samples when planarconfig is specified.
- Do not write RGB color images with 2 samples.
- Reorder TiffWriter.save keyword arguments (backward incompatible).
- 2016.4.18
- Pass 1932 tests.
- TiffWriter, imread, and imsave accept open binary file streams.
- 2016.04.13
- Correctly handle reversed fill order in 2 and 4 bps images (bug fix).
- Implement reverse_bitorder in C.
- 2016.03.18
- Fix saving additional ImageJ metadata.
- 2016.2.22
- Pass 1920 tests.
- Write 8 bytes double tag values using offset if necessary (bug fix).
- Add option to disable writing second image description tag.
- Detect tags with incorrect counts.
- Disable color mapping for LSM.
- 2015.11.13
- Read LSM 6 mosaics.
- Add option to specify directory of memory-mapped files.
- Add command line options to specify vmin and vmax values for colormapping.
- 2015.10.06
- New helper function to apply colormaps.
- Renamed is_palette attributes to is_indexed (backward incompatible).
- Color-mapped samples are now contiguous (backward incompatible).
- Do not color-map ImageJ hyperstacks (backward incompatible).
- Towards reading Leica SCN.
- 2015.9.25
- Read images with reversed bit order (FillOrder is LSB2MSB).
- 2015.9.21
- Read RGB OME-TIFF.
- Warn about malformed OME-XML.
- 2015.9.16
- Detect some corrupted ImageJ metadata.
- Better axes labels for 'shaped' files.
- Do not create TiffTag for default values.
- Chroma subsampling is not supported.
- Memory-map data in TiffPageSeries if possible (optional).
- 2015.8.17
- Pass 1906 tests.
- Write ImageJ hyperstacks (optional).
- Read and write LZMA compressed data.
- Specify datetime when saving (optional).
- Save tiled and color-mapped images (optional).
- Ignore void bytecounts and offsets if possible.
- Ignore bogus image_depth tag created by ISS Vista software.
- Decode floating point horizontal differencing (not tiled).
- Save image data contiguously if possible.
- Only read first IFD from ImageJ files if possible.
- Read ImageJ 'raw' format (files larger than 4 GB).
- TiffPageSeries class for pages with compatible shape and data type.
- Try to read incomplete tiles.
- Open file dialog if no filename is passed on command line.
- Ignore errors when decoding OME-XML.
- Rename decoder functions (backward incompatible).
- 2014.8.24
- TiffWriter class for incremental writing images.
- Simplify examples.
- 2014.8.19
- Add memmap function to FileHandle.
- Add function to determine if image data in TiffPage is memory-mappable.
- Do not close files if multifile_close parameter is False.
- 2014.8.10
- Pass 1730 tests.
- Return all extrasamples by default (backward incompatible).
- Read data from series of pages into memory-mapped array (optional).
- Squeeze OME dimensions (backward incompatible).
- Workaround missing EOI code in strips.
- Support image and tile depth tags (SGI extension).
- Better handling of STK/UIC tags (backward incompatible).
- Disable color mapping for STK.
- Julian to datetime converter.
- TIFF ASCII type may be NULL separated.
- Unwrap strip offsets for LSM files greater than 4 GB.
- Correct strip byte counts in compressed LSM files.
- Skip missing files in OME series.
- Read embedded TIFF files.
- 2014.2.05
- Save rational numbers as type 5 (bug fix).
- 2013.12.20
- Keep other files in OME multi-file series closed.
- FileHandle class to abstract binary file handle.
- Disable color mapping for bad OME-TIFF produced by bio-formats.
- Read bad OME-XML produced by ImageJ when cropping.
- 2013.11.3
- Allow zlib compress data in imsave function (optional).
- Memory-map contiguous image data (optional).
- 2013.10.28
- Read MicroManager metadata and little-endian ImageJ tag.
- Save extra tags in imsave function.
- Save tags in ascending order by code (bug fix).
- 2012.10.18
- Accept file like objects (read from OIB files).
- 2012.8.21
- Rename TIFFfile to TiffFile and TIFFpage to TiffPage.
- TiffSequence class for reading sequence of TIFF files.
- Read UltraQuant tags.
- Allow float numbers as resolution in imsave function.
- 2012.8.3
- Read MD GEL tags and NIH Image header.
- 2012.7.25
- Read ImageJ tags.
...
+ Refer to the CHANGES file for older revisions.
+
Notes
-----
The API is not stable yet and might change between revisions.
Tested on little-endian platforms only.
- Python 2.7, 3.4, and 32-bit versions are deprecated.
+ Python 32-bit versions are deprecated.
+
+ Update pip and setuptools to the latest version before installing tifffile:
+
+ ``python -m pip install --upgrade pip setuptools``
+
+ Tifffile relies on the `imagecodecs <https://pypi.org/project/imagecodecs/>`_
+ package for encoding and decoding LZW, JPEG, and other compressed images.
+
+ Several TIFF-like formats do not strictly adhere to the TIFF6 specification,
+ some of which allow file or data sizes to exceed the 4 GB limit:
+
+ * *BigTIFF* is identified by version number 43 and uses different file
+ header, IFD, and tag structures with 64-bit offsets. It adds more data types.
+ Tifffile can read and write BigTIFF files.
+ * *ImageJ* hyperstacks store all image data, which may exceed 4 GB,
+ contiguously after the first IFD. Files > 4 GB contain one IFD only.
+ The size (shape and dtype) of the up to 6-dimensional image data can be
+ determined from the ImageDescription tag of the first IFD, which is Latin-1
+ encoded. Tifffile can read and write ImageJ hyperstacks.
+ * *OME-TIFF* stores up to 8-dimensional data in one or multiple TIFF of BigTIFF
+ files. The 8-bit UTF-8 encoded OME-XML metadata found in the ImageDescription
+ tag of the first IFD defines the position of TIFF IFDs in the high
+ dimensional data. Tifffile can read OME-TIFF files, except when the OME-XML
+ metadata are stored in a separate file.
+ * *LSM* stores all IFDs below 4 GB but wraps around 32-bit StripOffsets.
+ The StripOffsets of each series and position require separate unwrapping.
+ The StripByteCounts tag contains the number of bytes for the uncompressed
+ data. Tifffile can read large LSM files.
+ * *NDPI* uses some 64-bit offsets in the file header, IFD, and tag structures.
+ Tag values/offsets can be corrected using high bits stored after IFD
+ structures. JPEG compressed tiles with dimensions > 65536 are not readable
+ with libjpeg. Tifffile can read NDPI files < 4 GB and decompress large JPEG
+ tiles using the imagecodecs library on Windows.
+ * *ScanImage* optionally allows corrupt non-BigTIFF files > 2 GB. The values
+ of StripOffsets and StripByteCounts can be recovered using the constant
+ differences of the offsets of IFD and tag values throughout the file.
+ Tifffile can read such files on Python 3 if the image data are stored
+ contiguously in each page.
+ * *GeoTIFF* sparse files allow strip or tile offsets and byte counts to be 0.
+ Such segments are implicitly set to 0 or the NODATA value on reading.
+ Tifffile can read GeoTIFF sparse files.
Other libraries for reading scientific TIFF files from Python:
- * `Python-bioformats <https://github.com/CellProfiler/python-bioformats>`_
- * `Imread <https://github.com/luispedro/imread>`_
- * `GDAL <https://github.com/OSGeo/gdal/tree/master/gdal/swig/python>`_
- * `OpenSlide-python <https://github.com/openslide/openslide-python>`_
- * `PyLibTiff <https://github.com/pearu/pylibtiff>`_
- * `SimpleITK <http://www.simpleitk.org>`_
- * `PyLSM <https://launchpad.net/pylsm>`_
- * `PyMca.TiffIO.py <https://github.com/vasole/pymca>`_ (same as fabio.TiffIO)
- * `BioImageXD.Readers <http://www.bioimagexd.net/>`_
- * `Cellcognition.io <http://cellcognition.org/>`_
- * `pymimage <https://github.com/ardoi/pymimage>`_
- * `pytiff <https://github.com/FZJ-INM1-BDA/pytiff>`_
-
- Acknowledgements
- ----------------
- * Egor Zindy, University of Manchester, for lsm_scan_info specifics.
- * Wim Lewis for a bug fix and some LSM functions.
- * Hadrien Mary for help on reading MicroManager files.
- * Christian Kliche for help writing tiled and color-mapped files.
+ * `Python-bioformats <https://github.com/CellProfiler/python-bioformats>`_
+ * `Imread <https://github.com/luispedro/imread>`_
+ * `GDAL <https://github.com/OSGeo/gdal/tree/master/gdal/swig/python>`_
+ * `OpenSlide-python <https://github.com/openslide/openslide-python>`_
+ * `PyLibTiff <https://github.com/pearu/pylibtiff>`_
+ * `SimpleITK <https://github.com/SimpleITK/SimpleITK>`_
+ * `PyLSM <https://launchpad.net/pylsm>`_
+ * `PyMca.TiffIO.py <https://github.com/vasole/pymca>`_ (same as fabio.TiffIO)
+ * `BioImageXD.Readers <http://www.bioimagexd.net/>`_
+ * `CellCognition <https://cellcognition-project.org/>`_
+ * `pymimage <https://github.com/ardoi/pymimage>`_
+ * `pytiff <https://github.com/FZJ-INM1-BDA/pytiff>`_
+ * `ScanImageTiffReaderPython
+ <https://gitlab.com/vidriotech/scanimagetiffreader-python>`_
+ * `bigtiff <https://pypi.org/project/bigtiff>`_
+
+ Some libraries are using tifffile to write OME-TIFF files:
+
+ * `Zeiss Apeer OME-TIFF library
+ <https://github.com/apeer-micro/apeer-ometiff-library>`_
+ * `Allen Institute for Cell Science imageio
+ <https://pypi.org/project/aicsimageio>`_
References
----------
- 1) TIFF 6.0 Specification and Supplements. Adobe Systems Incorporated.
+ 1. TIFF 6.0 Specification and Supplements. Adobe Systems Incorporated.
https://www.adobe.io/open/standards/TIFF.html
- 2) TIFF File Format FAQ. https://www.awaresystems.be/imaging/tiff/faq.html
- 3) MetaMorph Stack (STK) Image File Format.
+ 2. TIFF File Format FAQ. https://www.awaresystems.be/imaging/tiff/faq.html
+ 3. MetaMorph Stack (STK) Image File Format.
http://mdc.custhelp.com/app/answers/detail/a_id/18862
- 4) Image File Format Description LSM 5/7 Release 6.0 (ZEN 2010)..
+ 4. Image File Format Description LSM 5/7 Release 6.0 (ZEN 2010)..
Carl Zeiss MicroImaging GmbH. BioSciences. May 10, 2011
- 5) The OME-TIFF format.
+ 5. The OME-TIFF format.
https://docs.openmicroscopy.org/ome-model/5.6.4/ome-tiff/
- 6) UltraQuant(r) Version 6.0 for Windows Start-Up Guide.
+ 6. UltraQuant(r) Version 6.0 for Windows Start-Up Guide.
http://www.ultralum.com/images%20ultralum/pdf/UQStart%20Up%20Guide.pdf
- 7) Micro-Manager File Formats.
+ 7. Micro-Manager File Formats.
https://micro-manager.org/wiki/Micro-Manager_File_Formats
- 8) Tags for TIFF and Related Specifications. Digital Preservation.
+ 8. Tags for TIFF and Related Specifications. Digital Preservation.
https://www.loc.gov/preservation/digital/formats/content/tiff_tags.shtml
- 9) ScanImage BigTiff Specification - ScanImage 2016.
+ 9. ScanImage BigTiff Specification - ScanImage 2016.
http://scanimage.vidriotechnologies.com/display/SI2016/
ScanImage+BigTiff+Specification
- 10) CIPA DC-008-2016: Exchangeable image file format for digital still cameras:
+ 10. CIPA DC-008-2016: Exchangeable image file format for digital still cameras:
Exif Version 2.31.
http://www.cipa.jp/std/documents/e/DC-008-Translation-2016-E.pdf
- 11) ZIF, the Zoomable Image File format. http://zif.photo/
+ 11. ZIF, the Zoomable Image File format. http://zif.photo/
+ 12. GeoTIFF File Format https://gdal.org/drivers/raster/gtiff.html
Examples
--------
Save a 3D numpy array to a multi-page, 16-bit grayscale TIFF file:
- >>> data = numpy.random.randint(0, 2**16, (4, 301, 219), 'uint16')
+ >>> data = numpy.random.randint(0, 2**12, (4, 301, 219), 'uint16')
>>> imwrite('temp.tif', data, photometric='minisblack')
Read the whole image stack from the TIFF file as numpy array:
@@ -402,7 +315,7 @@ Description: Read and write TIFF(r) files
>>> image_stack.dtype
dtype('uint16')
- Read the image from first page (IFD) in the TIFF file:
+ Read the image from the first page in the TIFF file as numpy array:
>>> image = imread('temp.tif', key=0)
>>> image.shape
@@ -424,14 +337,36 @@ Description: Read and write TIFF(r) files
>>> data = numpy.random.rand(2, 5, 3, 301, 219).astype('float32')
>>> imwrite('temp.tif', data, compress=6, metadata={'axes': 'TZCYX'})
- Save a volume with xyz voxel size 2.6755x2.6755x3.9474 µm^3 to ImageJ file:
+ Save a volume with xyz voxel size 2.6755x2.6755x3.9474 micron^3 to an ImageJ
+ formatted TIFF file:
>>> volume = numpy.random.randn(57*256*256).astype('float32')
>>> volume.shape = 1, 57, 1, 256, 256, 1 # dimensions in TZCYXS order
>>> imwrite('temp.tif', volume, imagej=True, resolution=(1./2.6755, 1./2.6755),
... metadata={'spacing': 3.947368, 'unit': 'um'})
- Read hyperstack and metadata from ImageJ file:
+ Get the shape and dtype of the volume stored in the TIFF file:
+
+ >>> tif = TiffFile('temp.tif')
+ >>> len(tif.pages) # number of pages in the file
+ 57
+ >>> page = tif.pages[0] # get shape and dtype of the image in the first page
+ >>> page.shape
+ (256, 256)
+ >>> page.dtype
+ dtype('float32')
+ >>> page.axes
+ 'YX'
+ >>> series = tif.series[0] # get shape and dtype of the first image series
+ >>> series.shape
+ (57, 256, 256)
+ >>> series.dtype
+ dtype('float32')
+ >>> series.axes
+ 'ZYX'
+ >>> tif.close()
+
+ Read hyperstack and metadata from the ImageJ file:
>>> with TiffFile('temp.tif') as tif:
... imagej_hyperstack = tif.asarray()
@@ -441,35 +376,58 @@ Description: Read and write TIFF(r) files
>>> imagej_metadata['slices']
57
+ Read the "XResolution" tag from the first page in the TIFF file:
+
+ >>> with TiffFile('temp.tif') as tif:
+ ... tag = tif.pages[0].tags['XResolution']
+ >>> tag.value
+ (2000, 5351)
+ >>> tag.name
+ 'XResolution'
+ >>> tag.code
+ 282
+ >>> tag.count
+ 1
+ >>> tag.dtype
+ '2I'
+
+ Read images from a selected range of pages:
+
+ >>> image = imread('temp.tif', key=range(4, 40, 2))
+ >>> image.shape
+ (18, 256, 256)
+
Create an empty TIFF file and write to the memory-mapped numpy array:
>>> memmap_image = memmap('temp.tif', shape=(256, 256), dtype='float32')
>>> memmap_image[255, 255] = 1.0
>>> memmap_image.flush()
- >>> memmap_image.shape, memmap_image.dtype
- ((256, 256), dtype('float32'))
>>> del memmap_image
- Memory-map image data in the TIFF file:
+ Memory-map image data of the first page in the TIFF file:
>>> memmap_image = memmap('temp.tif', page=0)
>>> memmap_image[255, 255]
1.0
>>> del memmap_image
- Successively append images to a BigTIFF file:
+ Successively append images to a BigTIFF file, which can exceed 4 GB:
>>> data = numpy.random.randint(0, 255, (5, 2, 3, 301, 219), 'uint8')
>>> with TiffWriter('temp.tif', bigtiff=True) as tif:
... for i in range(data.shape[0]):
... tif.save(data[i], compress=6, photometric='minisblack')
+ Append an image to the existing TIFF file:
+
+ >>> data = numpy.random.randint(0, 255, (301, 219, 3), 'uint8')
+ >>> imwrite('temp.tif', data, append=True)
+
Iterate over pages and tags in the TIFF file and successively read images:
>>> with TiffFile('temp.tif') as tif:
- ... image_stack = tif.asarray()
... for page in tif.pages:
- ... for tag in page.tags.values():
+ ... for tag in page.tags:
... tag_name, tag_value = tag.name, tag.value
... image = page.asarray()
@@ -479,7 +437,7 @@ Description: Read and write TIFF(r) files
>>> data1 = numpy.random.randint(0, 255, (5, 301, 219), 'uint16')
>>> with TiffWriter('temp.tif') as tif:
... tif.save(data0, compress=6, photometric='rgb')
- ... tif.save(data1, compress=6, photometric='minisblack')
+ ... tif.save(data1, compress=6, photometric='minisblack', contiguous=False)
Read the second image series from the TIFF file:
@@ -487,7 +445,7 @@ Description: Read and write TIFF(r) files
>>> series1.shape
(5, 301, 219)
- Read an image stack from a sequence of TIFF files with a file name pattern:
+ Read an image stack from a series of TIFF files with a file name pattern:
>>> imwrite('temp_C001T001.tif', numpy.random.rand(64, 64))
>>> imwrite('temp_C001T002.tif', numpy.random.rand(64, 64))
@@ -500,18 +458,22 @@ Description: Read and write TIFF(r) files
>>> data.shape
(1, 2, 64, 64)
+ Create a TIFF file from an iterator of tiles:
+
+ >>> def tiles():
+ ... data = numpy.arange(3*4*16*16, dtype='uint16').reshape((3*4, 16, 16))
+ ... for i in range(data.shape[0]): yield data[i]
+ >>> imwrite('temp.tif', tiles(), dtype='uint16', shape=(48, 64), tile=(16, 16))
+
Platform: any
Classifier: Development Status :: 4 - Beta
Classifier: License :: OSI Approved :: BSD License
Classifier: Intended Audience :: Science/Research
Classifier: Intended Audience :: Developers
Classifier: Operating System :: OS Independent
-Classifier: Programming Language :: Python :: 2
-Classifier: Programming Language :: Python :: 2.7
-Classifier: Programming Language :: Python :: 3
-Classifier: Programming Language :: Python :: 3.4
-Classifier: Programming Language :: Python :: 3.5
+Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.6
Classifier: Programming Language :: Python :: 3.7
-Requires-Python: >=2.7
+Classifier: Programming Language :: Python :: 3.8
+Requires-Python: >=3.6
Provides-Extra: all
=====================================
tifffile.egg-info/SOURCES.txt
=====================================
@@ -1,9 +1,9 @@
+ACKNOWLEDGEMENTS.rst
+CHANGES.rst
LICENSE
MANIFEST.in
README.rst
setup.py
-setup_tiffile.py
-tiffile.py
tests/conftest.py
tests/test_tifffile.py
tifffile/__init__.py
=====================================
tifffile.egg-info/requires.txt
=====================================
@@ -1,13 +1,5 @@
-numpy>=1.11.3
-
-[:platform_system == "Windows"]
-imagecodecs>=2018.11.8
-
-[:python_version == "2.7"]
-pathlib
-enum34
-futures
+numpy>=1.15.1
+imagecodecs>=2020.2.18
[all]
-matplotlib>=2.2
-imagecodecs>=2018.11.8
+matplotlib>=3.1
=====================================
tifffile/__init__.py
=====================================
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
# tifffile/__init__.py
from .tifffile import __doc__, __all__, __version__, main
=====================================
tifffile/__main__.py
=====================================
@@ -1,6 +1,7 @@
-# -*- coding: utf-8 -*-
# tifffile/__main__.py
+"""Tifffile package command line script."""
+
import sys
from .tifffile import main
=====================================
tifffile/lsm2bin.py
=====================================
@@ -1,20 +1,21 @@
-# -*- coding: utf-8 -*-
+#!/usr/bin/env python3
# lsm2bin.py
-"""Convert *TZCYX LSM file to series of BIN files.
+"""Convert TZCYX LSM file to series of BIN files.
Usage: lsm2bin lsm_filename [bin_filename]
"""
-from __future__ import division, print_function
-
import sys
try:
from .tifffile import lsm2bin
except ImportError:
- from tifffile import lsm2bin
+ try:
+ from tifffile.tifffile import lsm2bin
+ except ImportError:
+ from tifffile import lsm2bin
def main(argv=None):
=====================================
tifffile/tifffile.py
=====================================
The diff for this file was not included because it is too large.
=====================================
tifffile/tifffile_geodb.py
=====================================
@@ -1,14 +1,17 @@
-# -*- coding: utf-8 -*-
# tifffile_geodb.py
-# GeoTIFF GeoKey Database
-# Adapted from http://gis.ess.washington.edu/data/raster/drg/docs/geotiff.txt
+"""GeoTIFF GeoKey Database.
+
+Adapted from http://gis.ess.washington.edu/data/raster/drg/docs/geotiff.txt
+
+"""
import enum
class Proj(enum.IntEnum):
"""Projection Codes."""
+
Undefined = 0
User_Defined = 32767
Alabama_CS27_East = 10101
@@ -440,6 +443,7 @@ class Proj(enum.IntEnum):
class PCS(enum.IntEnum):
"""Projected CS Type Codes."""
+
Undefined = 0
User_Defined = 32767
Adindan_UTM_zone_37N = 20137
@@ -1443,6 +1447,7 @@ class PCS(enum.IntEnum):
class GCSE(enum.IntEnum):
"""Unspecified GCS based on ellipsoid."""
+
Undefined = 0
User_Defined = 32767
Airy1830 = 4001
@@ -1484,6 +1489,7 @@ class GCSE(enum.IntEnum):
class GCS(enum.IntEnum):
"""Geographic CS Type Codes."""
+
Undefined = 0
User_Defined = 32767
Adindan = 4201
@@ -1631,6 +1637,7 @@ class GCS(enum.IntEnum):
class Ellipse(enum.IntEnum):
"""Ellipsoid Codes."""
+
Undefined = 0
User_Defined = 32767
Airy_1830 = 7001
@@ -1672,6 +1679,7 @@ class Ellipse(enum.IntEnum):
class DatumE(enum.IntEnum):
"""Ellipsoid-Only Geodetic Datum Codes."""
+
Undefined = 0
User_Defined = 32767
Airy1830 = 6001
@@ -1713,6 +1721,7 @@ class DatumE(enum.IntEnum):
class Datum(enum.IntEnum):
"""Geodetic Datum Codes."""
+
Undefined = 0
User_Defined = 32767
Adindan = 6201
@@ -1840,6 +1849,7 @@ class Datum(enum.IntEnum):
class ModelType(enum.IntEnum):
"""Model Type Codes."""
+
Undefined = 0
User_Defined = 32767
Projected = 1
@@ -1849,6 +1859,7 @@ class ModelType(enum.IntEnum):
class RasterPixel(enum.IntEnum):
"""Raster Type Codes."""
+
Undefined = 0
User_Defined = 32767
IsArea = 1
@@ -1857,6 +1868,7 @@ class RasterPixel(enum.IntEnum):
class Linear(enum.IntEnum):
"""Linear Units."""
+
Undefined = 0
User_Defined = 32767
Meter = 9001
@@ -1878,6 +1890,7 @@ class Linear(enum.IntEnum):
class Angular(enum.IntEnum):
"""Angular Units."""
+
Undefined = 0
User_Defined = 32767
Radian = 9101
@@ -1892,6 +1905,7 @@ class Angular(enum.IntEnum):
class PM(enum.IntEnum):
"""Prime Meridian Codes."""
+
Undefined = 0
User_Defined = 32767
Greenwich = 8901
@@ -1909,6 +1923,7 @@ class PM(enum.IntEnum):
class CT(enum.IntEnum):
"""Coordinate Transformation Codes."""
+
Undefined = 0
User_Defined = 32767
TransverseMercator = 1
@@ -1944,6 +1959,7 @@ class CT(enum.IntEnum):
class VertCS(enum.IntEnum):
"""Vertical CS Type Codes."""
+
Undefined = 0
User_Defined = 32767
Airy_1830_ellipsoid = 5001
=====================================
tiffile.py deleted
=====================================
@@ -1,12 +0,0 @@
-# -*- coding: utf-8 -*-
-# tiffile.py
-
-"""Proxy module for the tifffile package."""
-
-from tifffile.tifffile import __doc__, __all__, __version__ # noqa
-from tifffile.tifffile import lsm2bin, main # noqa
-from tifffile.tifffile import * # noqa
-
-if __name__ == '__main__':
- import sys
- sys.exit(main())
View it on GitLab: https://salsa.debian.org/python-team/modules/tifffile/-/commit/cddd23a49bc80e966691ecfd49a33ed1d72b4a1e
--
View it on GitLab: https://salsa.debian.org/python-team/modules/tifffile/-/commit/cddd23a49bc80e966691ecfd49a33ed1d72b4a1e
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/20200515/b3518e75/attachment-0001.html>
More information about the debian-med-commit
mailing list