*, index: Optional[int] = None, mode: Optional[str] = None, rotate: bool = False, apply_gamma: bool = False, writeable_output: bool = True, pilmode: Optional[str] = None, exifrotate: Optional[bool] = None, as_gray: Optional[bool] = None) ndarray[source]#

Parses the given URI and creates a ndarray from it.


If the ImageResource contains multiple ndimages, and index is an integer, select the index-th ndimage from among them and return it. If index is an ellipsis (…), read all ndimages in the file and stack them along a new batch dimension and return them. If index is None, this plugin reads the first image of the file (index=0) unless the image is a GIF or APNG, in which case all images are read (index=…).


Convert the image to the given mode before returning it. If None, the mode will be left unchanged. Possible modes can be found at:


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


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


If True, ensure that the image is writable before returning it to the user. This incurs a full copy of the pixel data if the data served by pillow is read-only. Consequentially, setting this flag to False improves performance for some images.


Deprecated, use mode instead.


Deprecated, use rotate instead.


Deprecated. Exists to raise a constructive error message.


A numpy array containing the loaded image data


If you read a paletted image (e.g. GIF) then the plugin will apply the palette by default. Should you wish to read the palette indices of each pixel use mode="P". The coresponding color pallete can be found in the image’s metadata using the palette key when metadata is extracted using the exclude_applied=False kwarg. The latter is needed, as palettes are applied by default and hence excluded by default to keep metadata and pixel data consistent.