docstr: Parses the given URI and creates a ndarray from it.
  
  Parameters
  ----------
  index : int
      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=...).
  mode : str
      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 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.
  writable_output : bool
      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.
  pilmode : str
      Deprecated, use `mode` instead.
  exifrotate : bool
      Deprecated, use `rotate` instead.
  as_gray : bool
      Deprecated. Exists to raise a constructive error message.
  
  Returns
  -------
  ndimage : ndarray
      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 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.
docstr_tok: ["Parses","the","given","URI","and","creates","a","ndarray","from","it",".","Parameters","--","--","--","--","--","index",":","int","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=","...",")",".","mode",":","str","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","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",".","writable_output",":","bool","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",".","pilmode",":","str","Deprecated",",","use","`","mode","`","instead",".","exifrotate",":","bool","Deprecated",",","use","`","rotate","`","instead",".","as_gray",":","bool","Deprecated",".","Exists","to","raise","a","constructive","error","message",".","Returns","--","--","--","-","ndimage",":","ndarray","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","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","."]
code: def read(
      self,
      *,
      index: int = None,
      mode: str = None,
      rotate: bool = False,
      apply_gamma: bool = False,
      writeable_output: bool = True,
      pilmode: str = None,
      exifrotate: bool = None,
      as_gray: bool = None,
  ) -> np.ndarray:
      """
      Parses the given URI and creates a ndarray from it.
  
      Parameters
      ----------
      index : int
          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=...).
      mode : str
          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 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.
      writable_output : bool
          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.
      pilmode : str
          Deprecated, use `mode` instead.
      exifrotate : bool
          Deprecated, use `rotate` instead.
      as_gray : bool
          Deprecated. Exists to raise a constructive error message.
  
      Returns
      -------
      ndimage : ndarray
          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 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.
  
      """
  
      if pilmode is not None:
          warnings.warn(
              "`pilmode` is deprecated. Use `mode` instead.",
              DeprecationWarning,
          )
          mode = pilmode
  
      if exifrotate is not None:
          warnings.warn(
              "`exifrotate` is deprecated. Use `rotate` instead.",
              DeprecationWarning,
          )
          rotate = exifrotate
  
      if as_gray is not None:
          raise TypeError(
              "The keyword `as_gray` is no longer supported."
              "Use `mode='F'` for a backward-compatible result, or "
              " `mode='L'` for an integer-valued result."
          )
  
      if self._image.format == "GIF":
          # Converting GIF P frames to RGB
          # https://github.com/python-pillow/Pillow/pull/6150
          GifImagePlugin.LOADING_STRATEGY = (
              GifImagePlugin.LoadingStrategy.RGB_AFTER_DIFFERENT_PALETTE_ONLY
          )
  
      if index is None:
          if self._image.format == "GIF":
              index = Ellipsis
          elif self._image.custom_mimetype == "image/apng":
              index = Ellipsis
          else:
              index = 0
  
      if isinstance(index, int):
          # will raise IO error if index >= number of frames in image
          self._image.seek(index)
          image = self._apply_transforms(
              self._image, mode, rotate, apply_gamma, writeable_output
          )
      else:
          iterator = self.iter(
              mode=mode,
              rotate=rotate,
              apply_gamma=apply_gamma,
              writeable_output=writeable_output,
          )
          image = np.stack([im for im in iterator], axis=0)
  
      return image
  
imports: import sys
  import warnings
  from io import BytesIO
  from typing import Any, Callable, Dict, Iterator, List, Optional, Tuple, Union, cast
  import numpy
  from PIL import ExifTags, GifImagePlugin, Image, ImageSequence, UnidentifiedImageError
  from PIL import __version__
  from ..core.request import URI_BYTES, InitializationError, IOMode, Request
  from ..core.v3_plugin_api import ImageProperties, PluginV3
  from ..typing import ArrayLike
label_desc: Use image node_id 3 for calling the PillowPlugin obj's underlying member method code with example usage: obj.read() and returns: image