| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
""" |
| 9 |
Imageio is a Python library that provides an easy interface to read and |
| 10 |
write a wide range of image data, including animated images, volumetric |
| 11 |
data, and scientific formats. It is cross-platform, runs on Python 3.10+, |
| 12 |
and is easy to install. |
| 13 |
|
| 14 |
Main website: https://imageio.readthedocs.io/ |
| 15 |
""" |
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
from importlib.metadata import version as get_version |
| 20 |
|
| 21 |
__version__ = get_version("imageio") |
| 22 |
|
| 23 |
|
| 24 |
import warnings |
| 25 |
|
| 26 |
|
| 27 |
from .core import FormatManager, RETURN_BYTES |
| 28 |
|
| 29 |
|
| 30 |
formats = FormatManager() |
| 31 |
show_formats = formats.show |
| 32 |
|
| 33 |
from . import v2 |
| 34 |
from . import v3 |
| 35 |
from . import plugins |
| 36 |
|
| 37 |
|
| 38 |
from . import config |
| 39 |
|
| 40 |
|
| 41 |
from .v2 import ( |
| 42 |
imread as imread_v2, |
| 43 |
mimread, |
| 44 |
volread, |
| 45 |
mvolread, |
| 46 |
imwrite, |
| 47 |
mimwrite, |
| 48 |
volwrite, |
| 49 |
mvolwrite, |
| 50 |
|
| 51 |
get_reader as read, |
| 52 |
get_writer as save, |
| 53 |
imwrite as imsave, |
| 54 |
mimwrite as mimsave, |
| 55 |
volwrite as volsave, |
| 56 |
mvolwrite as mvolsave, |
| 57 |
|
| 58 |
help, |
| 59 |
get_reader, |
| 60 |
get_writer, |
| 61 |
) |
| 62 |
from .v3 import ( |
| 63 |
imopen, |
| 64 |
|
| 65 |
|
| 66 |
imiter, |
| 67 |
) |
| 68 |
|
| 69 |
|
| 70 |
def imread(uri, format=None, **kwargs): |
| 71 |
"""imread(uri, format=None, **kwargs) |
| 72 |
|
| 73 |
Reads an image from the specified file. Returns a numpy array, which |
| 74 |
comes with a dict of meta data at its 'meta' attribute. |
| 75 |
|
| 76 |
Note that the image data is returned as-is, and may not always have |
| 77 |
a dtype of uint8 (and thus may differ from what e.g. PIL returns). |
| 78 |
|
| 79 |
Parameters |
| 80 |
---------- |
| 81 |
uri : {str, pathlib.Path, bytes, file} |
| 82 |
The resource to load the image from, e.g. a filename, pathlib.Path, |
| 83 |
http address or file object, see the docs for more info. |
| 84 |
format : str |
| 85 |
The format to use to read the file. By default imageio selects |
| 86 |
the appropriate for you based on the filename and its contents. |
| 87 |
kwargs : ... |
| 88 |
Further keyword arguments are passed to the reader. See :func:`.help` |
| 89 |
to see what arguments are available for a particular format. |
| 90 |
""" |
| 91 |
|
| 92 |
warnings.warn( |
| 93 |
"Starting with ImageIO v3 the behavior of this function will switch to that of" |
| 94 |
" iio.v3.imread. To keep the current behavior (and make this warning disappear)" |
| 95 |
" use `import imageio.v2 as imageio` or call `imageio.v2.imread` directly.", |
| 96 |
DeprecationWarning, |
| 97 |
stacklevel=2, |
| 98 |
) |
| 99 |
|
| 100 |
return imread_v2(uri, format=format, **kwargs) |
| 101 |
|
| 102 |
|
| 103 |
__all__ = [ |
| 104 |
"v2", |
| 105 |
"v3", |
| 106 |
"config", |
| 107 |
"plugins", |
| 108 |
|
| 109 |
"imopen", |
| 110 |
"imread", |
| 111 |
"imwrite", |
| 112 |
"imiter", |
| 113 |
|
| 114 |
"mimread", |
| 115 |
"volread", |
| 116 |
"mvolread", |
| 117 |
"imwrite", |
| 118 |
"mimwrite", |
| 119 |
"volwrite", |
| 120 |
"mvolwrite", |
| 121 |
|
| 122 |
"read", |
| 123 |
"save", |
| 124 |
"imsave", |
| 125 |
"mimsave", |
| 126 |
"volsave", |
| 127 |
"mvolsave", |
| 128 |
|
| 129 |
"help", |
| 130 |
"get_reader", |
| 131 |
"get_writer", |
| 132 |
"formats", |
| 133 |
"show_formats", |
| 134 |
] |