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

Method close

src/PIL/ImageFile.py:193–211  ·  view source on GitHub ↗

Closes the file pointer, if possible. This operation will destroy the image core and release its memory. The image data will be unusable afterward. This function is required to close images that have multiple frames or have not had their file read and close

(self)

Source from the content-addressed store, hash-verified

191 self.fp = None
192
193 def close(self) -> None:
194 """
195 Closes the file pointer, if possible.
196
197 This operation will destroy the image core and release its memory.
198 The image data will be unusable afterward.
199
200 This function is required to close images that have multiple frames or
201 have not had their file read and closed by the
202 :py:meth:`~PIL.Image.Image.load` method. See :ref:`file-handling` for
203 more information.
204 """
205 try:
206 self._close_fp()
207 self.fp = None
208 except Exception as msg:
209 logger.debug("Error closing: %s", msg)
210
211 super().close()
212
213 def get_child_images(self) -> list[ImageFile]:
214 child_images = []

Callers

nothing calls this directly

Calls 2

_close_fpMethod · 0.95
closeMethod · 0.45

Tested by

no test coverage detected