Skip to content

Commit dfb48ff

Browse files
committed
Match mask size to pasted image size
1 parent 1b67239 commit dfb48ff

2 files changed

Lines changed: 16 additions & 3 deletions

File tree

Tests/test_file_gif.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1105,6 +1105,21 @@ def im_generator(ims):
11051105
assert reread.n_frames == 10
11061106

11071107

1108+
def test_append_different_size_image(tmp_path: Path) -> None:
1109+
out = str(tmp_path / "temp.gif")
1110+
1111+
im = Image.new("RGB", (100, 100))
1112+
bigger_im = Image.new("RGB", (200, 200), "#f00")
1113+
1114+
im.save(out, save_all=True, append_images=[bigger_im])
1115+
1116+
with Image.open(out) as reread:
1117+
assert reread.size == (100, 100)
1118+
1119+
reread.seek(1)
1120+
assert reread.size == (100, 100)
1121+
1122+
11081123
def test_transparent_optimize(tmp_path: Path) -> None:
11091124
# From issue #2195, if the transparent color is incorrectly optimized out, GIF loses
11101125
# transparency.

src/PIL/GifImagePlugin.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -649,9 +649,7 @@ def _write_multiple_frames(im, fp, palette):
649649
if "transparency" in encoderinfo:
650650
# When the delta is zero, fill the image with transparency
651651
diff_frame = im_frame.copy()
652-
fill = Image.new(
653-
"P", diff_frame.size, encoderinfo["transparency"]
654-
)
652+
fill = Image.new("P", delta.size, encoderinfo["transparency"])
655653
if delta.mode == "RGBA":
656654
r, g, b, a = delta.split()
657655
mask = ImageMath.eval(

0 commit comments

Comments
 (0)