class_docstr: Class that for helping write the animated GIF file. This is based on
  code from images2gif.py (part of visvis). The version here is modified
  to allow streamed writing.
class_docstr_tok: ["Class","that","for","helping","write","the","animated","GIF","file",".","This","is","based","on","code","from","images2gif.py","(","part","of","visvis",")",".","The","version","here","is","modified","to","allow","streamed","writing","."]
code: def write_image(self, im, palette, rect, duration, dispose):
      fp = self.fp
  
      # Gather local image header and data, using PIL's getdata. That
      # function returns a list of bytes objects, but which parts are
      # what has changed multiple times, so we put together the first
      # parts until we have enough to form the image header.
      data = self.getdata(im)
      imdes = b""
      while data and len(imdes) < 11:
          imdes += data.pop(0)
      assert len(imdes) == 11
  
      # Make image descriptor suitable for using 256 local color palette
      lid = self.getImageDescriptor(im, rect)
      graphext = self.getGraphicsControlExt(duration, dispose)
  
      # Write local header
      if (palette != self._global_palette) or (dispose != 2):
          # Use local color palette
          fp.write(graphext)
          fp.write(lid)  # write suitable image descriptor
          fp.write(palette)  # write local color table
          fp.write(b"\x08")  # LZW minimum size code
      else:
          # Use global color palette
          fp.write(graphext)
          fp.write(imdes)  # write suitable image descriptor
  
      # Write image data
      for d in data:
          fp.write(d)
  
file_path: imageio/imageio/plugins/pillowmulti.py
imports: import logging
  import numpy
  from .pillow_legacy import PillowFormat, image_as_uint, ndarray_to_pil
label_desc: Use image node_id 5 for calling the GifWriter obj's underlying member method code with example usage: obj.write_image(im, palette, rect, duration, dispose) without return types