Skip to content

Commit

Permalink
Let tifffile.imread handle additional keyword arguments (#4997)
Browse files Browse the repository at this point in the history
  • Loading branch information
cgohlke committed Oct 2, 2020
1 parent a56c02f commit 94ccb86
Showing 1 changed file with 5 additions and 12 deletions.
17 changes: 5 additions & 12 deletions skimage/io/_plugins/tifffile_plugin.py
@@ -1,6 +1,6 @@
from warnings import warn
__all__ = ['imread', 'imsave']

from tifffile import TiffFile, imsave, parse_kwargs
from tifffile import imwrite as imsave, imread as tifffile_imread


def imread(fname, **kwargs):
Expand All @@ -16,22 +16,15 @@ def imread(fname, **kwargs):
Notes
-----
Provided by Christophe Golhke's tifffile.py [1]_, and supports many
Provided by the tifffile library [1]_, and supports many
advanced image types including multi-page and floating point.
References
----------
.. [1] http://www.lfd.uci.edu/~gohlke/code/tifffile.py
.. [1] https://pypi.org/project/tifffile/
"""
if 'img_num' in kwargs:
kwargs['key'] = kwargs.pop('img_num')

# parse_kwargs will extract keyword arguments intended for the TiffFile
# class and remove them from the kwargs dictionary in-place
tiff_keys = ['multifile', 'multifile_close', 'fastij', 'is_ome']
kwargs_tiff = parse_kwargs(kwargs, *tiff_keys)

# read and return tiff as numpy array
with TiffFile(fname, **kwargs_tiff) as tif:
return tif.asarray(**kwargs)
return tifffile_imread(fname, **kwargs)

0 comments on commit 94ccb86

Please sign in to comment.