Move the tifffile wrapper to tiff plugin

This commit is contained in:
Steven Silvester
2015-07-14 06:45:31 -05:00
parent 182a6f6904
commit b67a4e3076
2 changed files with 30 additions and 5 deletions
+2 -4
View File
@@ -5,7 +5,7 @@ from six import string_types
from PIL import Image
from ...util import img_as_ubyte, img_as_uint
from ...external.tifffile import TiffFile, imsave as tif_imsave
from .tifffile import imread as tif_imread, imsave as tif_imsave
def imread(fname, dtype=None, img_num=None, **kwargs):
@@ -41,9 +41,7 @@ def imread(fname, dtype=None, img_num=None, **kwargs):
if hasattr(fname, 'lower') and dtype is None:
kwargs.setdefault('key', img_num)
if fname.lower().endswith(('.tiff', '.tif')):
with open(fname, 'rb') as f:
tif = TiffFile(f)
return tif.asarray(**kwargs)
return tif_imread(fname, **kwargs)
if isinstance(fname, string_types):
with open(fname, 'rb') as f:
+28 -1
View File
@@ -1 +1,28 @@
from ...external.tifffile import imread, imsave
from ...external.tifffile import TiffFile, imsave
def imread(fname, dtype=None, **kwargs):
"""Load a tiff image from file.
Parameters
----------
fname : str or file
File name or file-like-object.
dtype : numpy dtype object or string specifier
Specifies data type of array elements (Not currently used).
kwargs : keyword pairs, optional
Addition keyword arguments to pass through (see `tifffile`'s `imread` function).
Notes
-----
Provided by Christophe Golhke's tifffile.py [1]_, and supports many
advanced image types including multi-page and floating point.
References
----------
.. [1] http://www.lfd.uci.edu/~gohlke/code/tifffile.py
"""
with open(fname, 'rb') as f:
tif = TiffFile(f)
return tif.asarray(**kwargs)