imageio.v3.imread#

imageio.v3.imread(uri, *, index: Optional[int] = 0, plugin: Optional[str] = None, format_hint: Optional[str] = None, **kwargs) numpy.ndarray#

Read an ndimage from a URI.

Opens the given URI and reads an ndimage from it. The exact behavior depends on both the file type and plugin used to open the file. To learn about the exact behavior, check the documentation of the relevant plugin. Typically, imread attempts to read all data stored in the URI.

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.

index{int, None}

If the URI contains multiple ndimages, select the index-th ndimage from among them and return it. The exact behavior is plugin dependent.

plugin{str, None}

The plugin to use. If set to None (default) imread will perform a search for a matching plugin. If not None, this takes priority over the provided format hint (if present).

format_hintstr

A format hint to help optimize plugin selection given as the format’s extension, e.g. “.png”. This can speed up the selection process for ImageResources that don’t have an explicit extension, e.g. streams, or for ImageResources where the extension does not match the resource’s content.

**kwargs

Additional keyword arguments will be passed to the plugin’s read call.

Returns
imagendimage

The ndimage located at the given URI.