mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-09-21 03:18:57 +03:00
Current delta is determined by previous disposal
This commit is contained in:
parent
e6a521130e
commit
430f50606e
|
@ -737,6 +737,25 @@ def test_dispose2_background_frame(tmp_path: Path) -> None:
|
||||||
assert im.n_frames == 3
|
assert im.n_frames == 3
|
||||||
|
|
||||||
|
|
||||||
|
def test_dispose2_previous_frame(tmp_path: Path) -> None:
|
||||||
|
out = str(tmp_path / "temp.gif")
|
||||||
|
|
||||||
|
im = Image.new("P", (100, 100))
|
||||||
|
im.info["transparency"] = 0
|
||||||
|
d = ImageDraw.Draw(im)
|
||||||
|
d.rectangle([(0, 0), (100, 50)], 1)
|
||||||
|
im.putpalette((0, 0, 0, 255, 0, 0))
|
||||||
|
|
||||||
|
im2 = Image.new("P", (100, 100))
|
||||||
|
im2.putpalette((0, 0, 0))
|
||||||
|
|
||||||
|
im.save(out, save_all=True, append_images=[im2], disposal=[0, 2])
|
||||||
|
|
||||||
|
with Image.open(out) as im:
|
||||||
|
im.seek(1)
|
||||||
|
assert im.getpixel((0, 0)) == (0, 0, 0, 255)
|
||||||
|
|
||||||
|
|
||||||
def test_transparency_in_second_frame(tmp_path: Path) -> None:
|
def test_transparency_in_second_frame(tmp_path: Path) -> None:
|
||||||
out = str(tmp_path / "temp.gif")
|
out = str(tmp_path / "temp.gif")
|
||||||
with Image.open("Tests/images/different_transparency.gif") as im:
|
with Image.open("Tests/images/different_transparency.gif") as im:
|
||||||
|
|
|
@ -629,7 +629,7 @@ def _write_multiple_frames(im, fp, palette):
|
||||||
"duration"
|
"duration"
|
||||||
]
|
]
|
||||||
continue
|
continue
|
||||||
if encoderinfo.get("disposal") == 2:
|
if im_frames[-1]["encoderinfo"].get("disposal") == 2:
|
||||||
if background_im is None:
|
if background_im is None:
|
||||||
color = im.encoderinfo.get(
|
color = im.encoderinfo.get(
|
||||||
"transparency", im.info.get("transparency", (0, 0, 0))
|
"transparency", im.info.get("transparency", (0, 0, 0))
|
||||||
|
@ -637,12 +637,8 @@ def _write_multiple_frames(im, fp, palette):
|
||||||
background = _get_background(im_frame, color)
|
background = _get_background(im_frame, color)
|
||||||
background_im = Image.new("P", im_frame.size, background)
|
background_im = Image.new("P", im_frame.size, background)
|
||||||
background_im.putpalette(im_frames[0]["im"].palette)
|
background_im.putpalette(im_frames[0]["im"].palette)
|
||||||
delta, bbox = _getbbox(background_im, im_frame)
|
bbox = _getbbox(background_im, im_frame)[1]
|
||||||
if (
|
elif encoderinfo.get("optimize") and im_frame.mode != "1":
|
||||||
encoderinfo.get("optimize")
|
|
||||||
and im_frames[-1]["encoderinfo"].get("disposal") != 2
|
|
||||||
and im_frame.mode != "1"
|
|
||||||
):
|
|
||||||
if "transparency" not in encoderinfo:
|
if "transparency" not in encoderinfo:
|
||||||
try:
|
try:
|
||||||
encoderinfo["transparency"] = (
|
encoderinfo["transparency"] = (
|
||||||
|
|
Loading…
Reference in New Issue
Block a user