MCPcopy Index your code
hub / github.com/python-pillow/Pillow / load

Method load

src/PIL/Image.py:968–1004  ·  view source on GitHub ↗

Allocates storage for the image and loads the pixel data. In normal cases, you don't need to call this method, since the Image class automatically loads an opened image when it is accessed for the first time. If the file associated with the image was opened

(self)

Source from the content-addressed store, hash-verified

966 raise ValueError(msg)
967
968 def load(self) -> core.PixelAccess | None:
969 """
970 Allocates storage for the image and loads the pixel data. In
971 normal cases, you don't need to call this method, since the
972 Image class automatically loads an opened image when it is
973 accessed for the first time.
974
975 If the file associated with the image was opened by Pillow, then this
976 method will close it. The exception to this is if the image has
977 multiple frames, in which case the file will be left open for seek
978 operations. See :ref:`file-handling` for more information.
979
980 :returns: An image access object.
981 :rtype: :py:class:`.PixelAccess`
982 """
983 if self._im is not None and self.palette and self.palette.dirty:
984 # realize palette
985 mode, arr = self.palette.getdata()
986 self.im.putpalette(self.palette.mode, mode, arr)
987 self.palette.dirty = 0
988 self.palette.rawmode = None
989 if "transparency" in self.info and mode in ("LA", "PA"):
990 if isinstance(self.info["transparency"], int):
991 self.im.putpalettealpha(self.info["transparency"], 0)
992 else:
993 self.im.putpalettealphas(self.info["transparency"])
994 self.palette.mode = "RGBA"
995 elif self.palette.mode != mode:
996 # If the palette rawmode is different to the mode,
997 # then update the Python palette data
998 self.palette.palette = self.im.getpalette(
999 self.palette.mode, self.palette.mode
1000 )
1001
1002 if self._im is not None:
1003 return self.im.pixel_access(self.readonly)
1004 return None
1005
1006 def verify(self) -> None:
1007 """

Callers 15

_copyMethod · 0.95
_ensure_mutableMethod · 0.95
__arrow_c_schema__Method · 0.95
__arrow_c_array__Method · 0.95
tobytesMethod · 0.95
tobitmapMethod · 0.95
convertMethod · 0.95
quantizeMethod · 0.95
copyMethod · 0.95
cropMethod · 0.95
filterMethod · 0.95
getbboxMethod · 0.95

Calls 3

putpaletteMethod · 0.80
getdataMethod · 0.45
getpaletteMethod · 0.45

Tested by

no test coverage detected