MCPcopy Create free account
hub / github.com/python-pillow/Pillow / setimage

Method setimage

src/PIL/ImageFile.py:789–822  ·  view source on GitHub ↗

Called from ImageFile to set the core output image for the codec :param im: A core image object :param extents: a 4 tuple of (x0, y0, x1, y1) defining the rectangle for this tile :returns: None

(
        self,
        im: Image.core.ImagingCore,
        extents: tuple[int, int, int, int] | None = None,
    )

Source from the content-addressed store, hash-verified

787 self.fd = fd
788
789 def setimage(
790 self,
791 im: Image.core.ImagingCore,
792 extents: tuple[int, int, int, int] | None = None,
793 ) -> None:
794 """
795 Called from ImageFile to set the core output image for the codec
796
797 :param im: A core image object
798 :param extents: a 4 tuple of (x0, y0, x1, y1) defining the rectangle
799 for this tile
800 :returns: None
801 """
802
803 # following c code
804 self.im = im
805
806 if extents:
807 x0, y0, x1, y1 = extents
808
809 if x0 < 0 or y0 < 0 or x1 > self.im.size[0] or y1 > self.im.size[1]:
810 msg = "Tile cannot extend outside image"
811 raise ValueError(msg)
812
813 self.state.xoff = x0
814 self.state.yoff = y0
815 self.state.xsize = x1 - x0
816 self.state.ysize = y1 - y0
817 else:
818 self.state.xsize, self.state.ysize = self.im.size
819
820 if self.state.xsize <= 0 or self.state.ysize <= 0:
821 msg = "Size must be positive"
822 raise ValueError(msg)
823
824
825class PyDecoder(PyCodec):

Callers 9

loadMethod · 0.80
feedMethod · 0.80
_encode_tileFunction · 0.80
set_as_rawMethod · 0.80
_load_libtiffMethod · 0.80
_saveFunction · 0.80
tobytesMethod · 0.80
frombytesMethod · 0.80

Calls

no outgoing calls

Tested by 1