class_docstr: A plugin to  make old (v2.9) plugins compatible with v3.0
  
  .. depreciated:: 2.9
      `legacy_get_reader` will be removed in a future version of imageio.
      `legacy_get_writer` will be removed in a future version of imageio.
  
  This plugin is a wrapper around the old FormatManager class and exposes
  all the old plugins via the new API. On top of this it has
  ``legacy_get_reader`` and ``legacy_get_writer`` methods to allow using
  it with the v2.9 API.
  
  Methods
  -------
  read(index=None, **kwargs)
      Read the image at position ``index``.
  write(image, **kwargs)
      Write image to the URI.
  iter(**kwargs)
      Iteratively yield images from the given URI.
  get_meta(index=None)
      Return the metadata for the image at position ``index``.
  legacy_get_reader(**kwargs)
      Returns the v2.9 image reader. (depreciated)
  legacy_get_writer(**kwargs)
      Returns the v2.9 image writer. (depreciated)
  
  Examples
  --------
  
  >>> import imageio.v3 as iio
  >>> with iio.imopen("/path/to/image.tiff", "r", legacy_mode=True) as file:
  >>>     reader = file.legacy_get_reader()  # depreciated
  >>>     for im in file.iter():
  >>>         print(im.shape)
class_docstr_tok: ["A","plugin","to","make","old","(","v2.9",")","plugins","compatible","with","v3.0","..","depreciated",":",":","2.9","`","legacy_get_reader","`","will","be","removed","in","a","future","version","of","imageio",".","`","legacy_get_writer","`","will","be","removed","in","a","future","version","of","imageio",".","This","plugin","is","a","wrapper","around","the","old","FormatManager","class","and","exposes","all","the","old","plugins","via","the","new","API",".","On","top","of","this","it","has","``","legacy_get_reader","``","and","``","legacy_get_writer","``","methods","to","allow","using","it","with","the","v2.9","API",".","Methods","--","--","--","-","read","(","index=None",",","*","*","kwargs",")","Read","the","image","at","position","``","index","``",".","write","(","image",",","*","*","kwargs",")","Write","image","to","the","URI",".","iter","(","*","*","kwargs",")","Iteratively","yield","images","from","the","given","URI",".","get_meta","(","index=None",")","Return","the","metadata","for","the","image","at","position","``","index","``",".","legacy_get_reader","(","*","*","kwargs",")","Returns","the","v2.9","image","reader",".","(","depreciated",")","legacy_get_writer","(","*","*","kwargs",")","Returns","the","v2.9","image","writer",".","(","depreciated",")","Examples","--","--","--","--",">",">",">","import","imageio.v3","as","iio",">",">",">","with","iio.imopen","(","``","\/path\/to\/image.tiff","''",",","``","r","''",",","legacy_mode=True",")","as","file",":",">",">",">","reader","=","file.legacy_get_reader","(",")","#","depreciated",">",">",">","for","im","in","file.iter","(",")",":",">",">",">","print","(","im.shape",")"]
docstr: Write an ndimage to the URI specified in path.
  
  If the URI points to a file on the current host and the file does not
  yet exist it will be created. If the file exists already, it will be
  appended if possible; otherwise, it will be replaced.
  
  Parameters
  ----------
  ndimage : numpy.ndarray
      The ndimage or list of ndimages to write.
  is_batch : bool
      If True, treat the supplied ndimage as a batch of images. If False,
      treat the supplied ndimage as a single image. If None, try to
      determine ``is_batch`` from the ndimage's shape and ndim.
  metadata : dict
      The metadata passed to write alongside the image.
  kwargs : ...
      Further keyword arguments are passed to the writer. See
      :func:`.help` to see what arguments are available for a
      particular format.
  
  
  Returns
  -------
  buffer : bytes
      When writing to the special target "<bytes>", this function will
      return the encoded image data as a bytes string. Otherwise it
      returns None.
  
  Notes
  -----
  Automatically determining ``is_batch`` may fail for some images due to
  shape aliasing. For example, it may classify a channel-first color image
  as a batch of gray images. In most cases this automatic deduction works
  fine (it has for almost a decade), but if you do have one of those edge
  cases (or are worried that you might) consider explicitly setting
  ``is_batch``.
docstr_tok: ["Write","an","ndimage","to","the","URI","specified","in","path",".","If","the","URI","points","to","a","file","on","the","current","host","and","the","file","does","not","yet","exist","it","will","be","created",".","If","the","file","exists","already",",","it","will","be","appended","if","possible",";","otherwise",",","it","will","be","replaced",".","Parameters","--","--","--","--","--","ndimage",":","numpy.ndarray","The","ndimage","or","list","of","ndimages","to","write",".","is_batch",":","bool","If","True",",","treat","the","supplied","ndimage","as","a","batch","of","images",".","If","False",",","treat","the","supplied","ndimage","as","a","single","image",".","If","None",",","try","to","determine","``","is_batch","``","from","the","ndimage","'s","shape","and","ndim",".","metadata",":","dict","The","metadata","passed","to","write","alongside","the","image",".","kwargs",":","...","Further","keyword","arguments","are","passed","to","the","writer",".","See",":","func",":","`",".help","`","to","see","what","arguments","are","available","for","a","particular","format",".","Returns","--","--","--","-","buffer",":","bytes","When","writing","to","the","special","target","``","<","bytes",">","''",",","this","function","will","return","the","encoded","image","data","as","a","bytes","string",".","Otherwise","it","returns","None",".","Notes","--","--","-","Automatically","determining","``","is_batch","``","may","fail","for","some","images","due","to","shape","aliasing",".","For","example",",","it","may","classify","a","channel-first","color","image","as","a","batch","of","gray","images",".","In","most","cases","this","automatic","deduction","works","fine","(","it","has","for","almost","a","decade",")",",","but","if","you","do","have","one","of","those","edge","cases","(","or","are","worried","that","you","might",")","consider","explicitly","setting","``","is_batch","``","."]
code: def write(self, ndimage, *, is_batch=None, metadata=None, **kwargs):
      """
      Write an ndimage to the URI specified in path.
  
      If the URI points to a file on the current host and the file does not
      yet exist it will be created. If the file exists already, it will be
      appended if possible; otherwise, it will be replaced.
  
      Parameters
      ----------
      ndimage : numpy.ndarray
          The ndimage or list of ndimages to write.
      is_batch : bool
          If True, treat the supplied ndimage as a batch of images. If False,
          treat the supplied ndimage as a single image. If None, try to
          determine ``is_batch`` from the ndimage's shape and ndim.
      metadata : dict
          The metadata passed to write alongside the image.
      kwargs : ...
          Further keyword arguments are passed to the writer. See
          :func:`.help` to see what arguments are available for a
          particular format.
  
  
      Returns
      -------
      buffer : bytes
          When writing to the special target "<bytes>", this function will
          return the encoded image data as a bytes string. Otherwise it
          returns None.
  
      Notes
      -----
      Automatically determining ``is_batch`` may fail for some images due to
      shape aliasing. For example, it may classify a channel-first color image
      as a batch of gray images. In most cases this automatic deduction works
      fine (it has for almost a decade), but if you do have one of those edge
      cases (or are worried that you might) consider explicitly setting
      ``is_batch``.
  
      """
  
      if is_batch or isinstance(ndimage, (list, tuple)):
          pass  # ndimage is list of images
      elif is_batch is False:
          ndimage = [ndimage]
      else:
          # Write the largest possible block by guessing the meaning of each
          # dimension from the shape/ndim and then checking if any batch
          # dimensions are left.
          ndimage = np.asanyarray(ndimage)
          batch_dims = ndimage.ndim
  
          # two spatial dimensions
          batch_dims = max(batch_dims - 2, 0)
  
          # packed (channel-last) image
          if ndimage.ndim >= 3 and ndimage.shape[-1] < 5:
              batch_dims = max(batch_dims - 1, 0)
  
          # format supports volumetric images
          ext_infos = known_extensions.get(
              self._request.extension, list()
          )
          for ext_info in ext_infos:
              if (
                  self._format.name in ext_info.priority
                  and ext_info.volume_support
              ):
                  batch_dims = max(batch_dims - 1, 0)
                  break
  
          if batch_dims == 0:
              ndimage = [ndimage]
  
      with self.legacy_get_writer(**kwargs) as writer:
          for image in ndimage:
              image = np.asanyarray(image)
  
              if image.ndim < 2:
                  raise ValueError(
                      "The image must have at least two spatial dimensions."
                  )
  
              if not np.issubdtype(
                  image.dtype, np.number
              ) and not np.issubdtype(image.dtype, bool):
                  raise ValueError(
                      f"All images have to be numeric, and not `{image.dtype}`."
                  )
  
              writer.append_data(image, metadata)
  
      return writer.request.get_result()
  
file_path: imageio/imageio/core/legacy_plugin_wrapper.py
imports: from pathlib import Path
  import numpy
  from ..config import known_extensions
  from .request import InitializationError, IOMode
  from .v3_plugin_api import ImageProperties, PluginV3
label_desc: Use image node_id 5 for calling the LegacyPlugin obj's underlying member method code with example usage: obj.write(ndimage) and returns: writer