docstr: Instantiate a new Pillow Plugin Object
  
  Parameters
  ----------
  request : {Request}
      A request object representing the resource to be operated on.
docstr_tok: ["Instantiate","a","new","Pillow","Plugin","Object","Parameters","--","--","--","--","--","request",":","{","Request","}","A","request","object","representing","the","resource","to","be","operated","on","."]
code: def __init__(self, request: Request) -> None:
      """Instantiate a new Pillow Plugin Object
  
      Parameters
      ----------
      request : {Request}
          A request object representing the resource to be operated on.
  
      """
  
      super().__init__(request)
  
      # Register HEIF opener for Pillow
      try:
          from pillow_heif import register_heif_opener
      except ImportError:
          pass
      else:
          register_heif_opener()
  
      # Register AVIF opener for Pillow
      try:
          from pillow_heif import register_avif_opener
      except ImportError:
          pass
      else:
          register_avif_opener()
  
      self._image: Image = None
      self.images_to_write = []
  
      if request.mode.io_mode == IOMode.read:
          try:
              with Image.open(request.get_file()):
                  # Check if it is generally possible to read the image.
                  # This will not read any data and merely try to find a
                  # compatible pillow plugin (ref: the pillow docs).
                  pass
          except UnidentifiedImageError:
              if request._uri_type == URI_BYTES:
                  raise InitializationError(
                      "Pillow can not read the provided bytes."
                  ) from None
              else:
                  raise InitializationError(
                      f"Pillow can not read {request.raw_uri}."
                  ) from None
  
          self._image = Image.open(self._request.get_file())
      else:
          self.save_args = {}
  
          extension = self.request.extension or self.request.format_hint
          if extension is None:
              warnings.warn(
                  "Can't determine file format to write as. You _must_"
                  " set `format` during write or the call will fail. Use "
                  "`extension` to supress this warning. ",
                  UserWarning,
              )
              return
  
          tirage = [Image.preinit, Image.init]
          for format_loader in tirage:
              format_loader()
              if extension in Image.registered_extensions().keys():
                  return
  
          raise InitializationError(
              f"Pillow can not write `{extension}` files."
          ) from None
  
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 1 to create a new PillowPlugin object from inherited base classes: PluginV3 with example: obj = PillowPlugin(request)