Added file handling links in documentation

This commit is contained in:
Andrew Murray 2018-06-30 16:44:59 +10:00
parent fdbd719da4
commit d9653a48c7
2 changed files with 9 additions and 4 deletions

View File

@ -1,3 +1,5 @@
.. _file-handling:
File Handling in Pillow File Handling in Pillow
======================= =======================

View File

@ -572,7 +572,8 @@ class Image(object):
This function is only required to close images that have not This function is only required to close images that have not
had their file read and closed by the had their file read and closed by the
:py:meth:`~PIL.Image.Image.load` method. :py:meth:`~PIL.Image.Image.load` method. See
:ref:`file-handling` for more information.
""" """
try: try:
self.fp.close() self.fp.close()
@ -802,8 +803,10 @@ class Image(object):
Allocates storage for the image and loads the pixel data. In Allocates storage for the image and loads the pixel data. In
normal cases, you don't need to call this method, since the normal cases, you don't need to call this method, since the
Image class automatically loads an opened image when it is Image class automatically loads an opened image when it is
accessed for the first time. This method will close the file accessed for the first time.
associated with the image.
This method will close the file associated with the image. See
:ref:`file-handling` for more information.
:returns: An image access object. :returns: An image access object.
:rtype: :ref:`PixelAccess` or :py:class:`PIL.PyAccess` :rtype: :ref:`PixelAccess` or :py:class:`PIL.PyAccess`
@ -2547,7 +2550,7 @@ def open(fp, mode="r"):
the file remains open and the actual image data is not read from the file remains open and the actual image data is not read from
the file until you try to process the data (or call the the file until you try to process the data (or call the
:py:meth:`~PIL.Image.Image.load` method). See :py:meth:`~PIL.Image.Image.load` method). See
:py:func:`~PIL.Image.new`. :py:func:`~PIL.Image.new`. See :ref:`file-handling`.
:param fp: A filename (string), pathlib.Path object or a file object. :param fp: A filename (string), pathlib.Path object or a file object.
The file object must implement :py:meth:`~file.read`, The file object must implement :py:meth:`~file.read`,