imageio.plugins.pillow.PillowPlugin.read

PillowPlugin.read(*, index=None, mode=None, rotate=False, apply_gamma=False)

Parses the given URI and creates a ndarray from it.

Parameters
index{integer}

If the URI contains a list of ndimages (multiple frames) return the index-th image/frame. If None, read all ndimages (frames) in the URI and attempt to stack them along a new 0-th axis (equivalent to np.stack(imgs, axis=0))

mode{str, None}

Convert the image to the given mode before returning it. If None, the mode will be left unchanged. Possible modes can be found at: https://pillow.readthedocs.io/en/stable/handbook/concepts.html#modes

rotate{bool}

If set to True and the image contains an EXIF orientation tag, apply the orientation before returning the ndimage.

apply_gamma{bool}

If True and the image contains metadata about gamma, apply gamma correction to the image.

Returns
ndimagendarray

A numpy array containing the loaded image data

Notes

If you open a GIF - or any other format using color pallets - you may wish to manually set the mode parameter. Otherwise, the numbers in the returned image will refer to the entries in the color pallet, which is discarded during conversion to ndarray.