Skip to content

Commit 68e39cb

Browse files
authored
Merge pull request #6313 from radarhere/documentation
Improved image file formats documentation
2 parents 30a0e44 + 7c031e9 commit 68e39cb

File tree

1 file changed

+8
-11
lines changed

1 file changed

+8
-11
lines changed

docs/handbook/image-file-formats.rst

+8-11
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ When an image is opened from a file, only that instance of the image is consider
1717
have the format. Copies of the image will contain data loaded from the file, but not
1818
the file itself, meaning that it can no longer be considered to be in the original
1919
format. So if :py:meth:`~PIL.Image.Image.copy` is called on an image, or another method
20-
internally creates a copy of the image, the ``fp`` (file pointer), along with any
21-
methods and attributes specific to a format. The :py:attr:`~PIL.Image.Image.format`
22-
attribute will be ``None``.
20+
internally creates a copy of the image, then any methods or attributes specific to the
21+
format will no longer be present. The ``fp`` (file pointer) attribute will no longer be
22+
present, and the :py:attr:`~PIL.Image.Image.format` attribute will be ``None``.
2323

2424
Fully supported formats
2525
-----------------------
@@ -101,8 +101,8 @@ GIF
101101
^^^
102102

103103
Pillow reads GIF87a and GIF89a versions of the GIF file format. The library
104-
writes LZW encoded files in GIF87a by default, unless GIF89a features
105-
are used or GIF89a is already in use.
104+
writes files in GIF87a by default, unless GIF89a features are used or GIF89a is
105+
already in use. Files are written with LZW encoding.
106106

107107
GIF files are initially read as grayscale (``L``) or palette mode (``P``)
108108
images. Seeking to later frames in a ``P`` image will change the image to
@@ -245,17 +245,14 @@ Reading local images
245245

246246
The GIF loader creates an image memory the same size as the GIF file’s *logical
247247
screen size*, and pastes the actual pixel data (the *local image*) into this
248-
image. If you only want the actual pixel rectangle, you can manipulate the
249-
:py:attr:`~PIL.Image.Image.size` and :py:attr:`~PIL.ImageFile.ImageFile.tile`
250-
attributes before loading the file::
248+
image. If you only want the actual pixel rectangle, you can crop the image::
251249

252250
im = Image.open(...)
253251

254252
if im.tile[0][0] == "gif":
255253
# only read the first "local image" from this GIF file
256-
tag, (x0, y0, x1, y1), offset, extra = im.tile[0]
257-
im.size = (x1 - x0, y1 - y0)
258-
im.tile = [(tag, (0, 0) + im.size, offset, extra)]
254+
box = im.tile[0][1]
255+
im = im.crop(box)
259256

260257
ICNS
261258
^^^^

0 commit comments

Comments
 (0)