mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-12-24 17:06:16 +03:00
Allow alpha differences to indicate different frames when saving GIF
This commit is contained in:
parent
119a0dfb01
commit
541d2605b9
|
@ -1130,6 +1130,18 @@ def test_bbox(tmp_path):
|
|||
assert reread.n_frames == 2
|
||||
|
||||
|
||||
def test_bbox_alpha(tmp_path):
|
||||
out = str(tmp_path / "temp.gif")
|
||||
|
||||
im = Image.new("RGBA", (1, 2), (255, 0, 0, 255))
|
||||
im.putpixel((0, 1), (255, 0, 0, 0))
|
||||
im2 = Image.new("RGBA", (1, 2), (255, 0, 0, 0))
|
||||
im.save(out, save_all=True, append_images=[im2])
|
||||
|
||||
with Image.open(out) as reread:
|
||||
assert reread.n_frames == 2
|
||||
|
||||
|
||||
def test_palette_save_L(tmp_path):
|
||||
# Generate an L mode image with a separate palette
|
||||
|
||||
|
|
|
@ -569,9 +569,9 @@ def _getbbox(base_im, im_frame):
|
|||
delta = ImageChops.subtract_modulo(im_frame, base_im)
|
||||
else:
|
||||
delta = ImageChops.subtract_modulo(
|
||||
im_frame.convert("RGB"), base_im.convert("RGB")
|
||||
im_frame.convert("RGBA"), base_im.convert("RGBA")
|
||||
)
|
||||
return delta.getbbox()
|
||||
return delta.getbbox(alpha_only=False)
|
||||
|
||||
|
||||
def _write_multiple_frames(im, fp, palette):
|
||||
|
|
|
@ -1140,7 +1140,7 @@ def _write_multiple_frames(im, fp, chunk, rawmode, default_image, append_images)
|
|||
delta = ImageChops.subtract_modulo(
|
||||
im_frame.convert("RGBA"), base_im.convert("RGBA")
|
||||
)
|
||||
bbox = delta.im.getbbox(False)
|
||||
bbox = delta.getbbox(alpha_only=False)
|
||||
if (
|
||||
not bbox
|
||||
and prev_disposal == encoderinfo.get("disposal")
|
||||
|
|
Loading…
Reference in New Issue
Block a user