imageio.plugins.pillow.PillowPlugin.read#
- PillowPlugin.read(*, index=None, mode=None, pilmode=None, rotate=False, exifrotate=None, apply_gamma=False, as_gray=None) ndarray[source]#
Parses the given URI and creates a ndarray from it.
- Parameters:
- indexint
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=…).
- modestr
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
- pilmodestr
Deprecated, use mode instead.
- rotatebool
If set to
Trueand the image contains an EXIF orientation tag, apply the orientation before returning the ndimage.- exifrotatebool
Deprecated, use rotate instead.
- apply_gammabool
If
Trueand the image contains metadata about gamma, apply gamma correction to the image.- as_graybool
Deprecated. Exists to raise a constructive error message.
- Returns:
- ndimagendarray
A numpy array containing the loaded image data
Notes
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 thepalettekey when metadata is extracted using theexclude_applied=Falsekwarg. The latter is needed, as palettes are applied by default and hence excluded by default to keep metadata and pixel data consistent.