|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
""" |
|
|
Imageio is a Python library that provides an easy interface to read and |
|
|
write a wide range of image data, including animated images, volumetric |
|
|
data, and scientific formats. It is cross-platform, runs on Python 3.9+, |
|
|
and is easy to install. |
|
|
|
|
|
Main website: https://imageio.readthedocs.io/ |
|
|
""" |
|
|
|
|
|
|
|
|
|
|
|
__version__ = "2.36.1" |
|
|
|
|
|
import warnings |
|
|
|
|
|
|
|
|
from .core import FormatManager, RETURN_BYTES |
|
|
|
|
|
|
|
|
formats = FormatManager() |
|
|
show_formats = formats.show |
|
|
|
|
|
from . import v2 |
|
|
from . import v3 |
|
|
from . import plugins |
|
|
|
|
|
|
|
|
from . import config |
|
|
|
|
|
|
|
|
from .v2 import ( |
|
|
imread as imread_v2, |
|
|
mimread, |
|
|
volread, |
|
|
mvolread, |
|
|
imwrite, |
|
|
mimwrite, |
|
|
volwrite, |
|
|
mvolwrite, |
|
|
|
|
|
get_reader as read, |
|
|
get_writer as save, |
|
|
imwrite as imsave, |
|
|
mimwrite as mimsave, |
|
|
volwrite as volsave, |
|
|
mvolwrite as mvolsave, |
|
|
|
|
|
help, |
|
|
get_reader, |
|
|
get_writer, |
|
|
) |
|
|
from .v3 import ( |
|
|
imopen, |
|
|
|
|
|
|
|
|
imiter, |
|
|
) |
|
|
|
|
|
|
|
|
def imread(uri, format=None, **kwargs): |
|
|
"""imread(uri, format=None, **kwargs) |
|
|
|
|
|
Reads an image from the specified file. Returns a numpy array, which |
|
|
comes with a dict of meta data at its 'meta' attribute. |
|
|
|
|
|
Note that the image data is returned as-is, and may not always have |
|
|
a dtype of uint8 (and thus may differ from what e.g. PIL returns). |
|
|
|
|
|
Parameters |
|
|
---------- |
|
|
uri : {str, pathlib.Path, bytes, file} |
|
|
The resource to load the image from, e.g. a filename, pathlib.Path, |
|
|
http address or file object, see the docs for more info. |
|
|
format : str |
|
|
The format to use to read the file. By default imageio selects |
|
|
the appropriate for you based on the filename and its contents. |
|
|
kwargs : ... |
|
|
Further keyword arguments are passed to the reader. See :func:`.help` |
|
|
to see what arguments are available for a particular format. |
|
|
""" |
|
|
|
|
|
warnings.warn( |
|
|
"Starting with ImageIO v3 the behavior of this function will switch to that of" |
|
|
" iio.v3.imread. To keep the current behavior (and make this warning disappear)" |
|
|
" use `import imageio.v2 as imageio` or call `imageio.v2.imread` directly.", |
|
|
DeprecationWarning, |
|
|
stacklevel=2, |
|
|
) |
|
|
|
|
|
return imread_v2(uri, format=format, **kwargs) |
|
|
|
|
|
|
|
|
__all__ = [ |
|
|
"v2", |
|
|
"v3", |
|
|
"config", |
|
|
"plugins", |
|
|
|
|
|
"imopen", |
|
|
"imread", |
|
|
"imwrite", |
|
|
"imiter", |
|
|
|
|
|
"mimread", |
|
|
"volread", |
|
|
"mvolread", |
|
|
"imwrite", |
|
|
"mimwrite", |
|
|
"volwrite", |
|
|
"mvolwrite", |
|
|
|
|
|
"read", |
|
|
"save", |
|
|
"imsave", |
|
|
"mimsave", |
|
|
"volsave", |
|
|
"mvolsave", |
|
|
|
|
|
"help", |
|
|
"get_reader", |
|
|
"get_writer", |
|
|
"formats", |
|
|
"show_formats", |
|
|
] |
|
|
|