class_docstr: Python implementation of a format decoder. Override this class and
  add the decoding logic in the :meth:`decode` method.
  
  See :ref:`Writing Your Own File Decoder in Python<file-decoders-py>`
docstr: Called from ImageFile to set the core output image for the decoder
  
  :param im: A core image object
  :param extents: a 4 tuple of (x0, y0, x1, y1) defining the rectangle
      for this tile
  :returns: None
docstr_tok: ["Called","from","ImageFile","to","set","the","core","output","image","for","the","decoder",":","param","im",":","A","core","image","object",":","param","extents",":","a","4","tuple","of","(","x0",",","y0",",","x1",",","y1",")","defining","the","rectangle","for","this","tile",":","returns",":","None"]
code: def setimage(self, im, extents=None):
      """
      Called from ImageFile to set the core output image for the decoder
  
      :param im: A core image object
      :param extents: a 4 tuple of (x0, y0, x1, y1) defining the rectangle
          for this tile
      :returns: None
      """
  
      # following c code
      self.im = im
  
      if extents:
          (x0, y0, x1, y1) = extents
      else:
          (x0, y0, x1, y1) = (0, 0, 0, 0)
  
      if x0 == 0 and x1 == 0:
          self.state.xsize, self.state.ysize = self.im.size
      else:
          self.state.xoff = x0
          self.state.yoff = y0
          self.state.xsize = x1 - x0
          self.state.ysize = y1 - y0
  
      if self.state.xsize <= 0 or self.state.ysize <= 0:
          raise ValueError("Size cannot be negative")
  
      if (
          self.state.xsize + self.state.xoff > self.im.size[0]
          or self.state.ysize + self.state.yoff > self.im.size[1]
      ):
          raise ValueError("Tile cannot extend outside image")
  
imports: import io
  import itertools
  import struct
  import sys
  from .None import Image
  from ._util import isPath
label_desc: Use image node_id 7 for calling the PyDecoder obj's underlying member method code with example usage: obj.setimage(im, extents) without return types