-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Description
The GIF file test_extents() test
Lines 1381 to 1390 in 6a9acfa
| def test_extents() -> None: | |
| with Image.open("Tests/images/test_extents.gif") as im: | |
| assert im.size == (100, 100) | |
| # Check that n_frames does not change the size | |
| assert im.n_frames == 2 | |
| assert im.size == (100, 100) | |
| im.seek(1) | |
| assert im.size == (150, 150) |
tests that an image with two frames, where the second frame is offset from the first, will change the size of the image. The actual frame data is that each frame is 100x100, and the second frame is offset by 50 pixels both right and down. Here's an equivalent image with different colored frames (to make it easier to see them):
created with ImageMagick magick -delay 50 -size 100x100 xc:#FF0000 ( xc:#0000FF -set page +50+50 ) grow.gif
Logically, when overlaying one image onto another with an offset, the size of the image will increase by that offset. However, I have not found any application that actually does this when displaying this GIF. Every application I have tried has kept the size of the first frame, cutting off any pixels from the second frame that extend beyond that. ffplay even gives a warning message: "Image too wide by 50, truncating."
Based on this real-world testing, I think Pillow should probably do the same as everyone else and not change the image size when the GIF frames are different sizes.
It also seems that behind the scenes, the image is not actually 150x150. len(im.getdata()) at the end of that test is 10000, not 22500, and im.getpixel((123,123)) raises an IndexError.
