Skip to content

Commit 533c907

Browse files
committed
Updated example in light of #3203
1 parent 3efe344 commit 533c907

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

docs/handbook/image-file-formats.rst

+3-6
Original file line numberDiff line numberDiff line change
@@ -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)