@@ -647,6 +647,9 @@ def test_dispose2_palette(tmp_path: Path) -> None:
647647 # Center remains red every frame
648648 assert rgb_img .getpixel ((50 , 50 )) == circle
649649
650+ # Check that frame transparency wasn't added unnecessarily
651+ assert img ._frame_transparency is None
652+
650653
651654def test_dispose2_diff (tmp_path : Path ) -> None :
652655 out = str (tmp_path / "temp.gif" )
@@ -734,6 +737,25 @@ def test_dispose2_background_frame(tmp_path: Path) -> None:
734737 assert im .n_frames == 3
735738
736739
740+ def test_dispose2_previous_frame (tmp_path : Path ) -> None :
741+ out = str (tmp_path / "temp.gif" )
742+
743+ im = Image .new ("P" , (100 , 100 ))
744+ im .info ["transparency" ] = 0
745+ d = ImageDraw .Draw (im )
746+ d .rectangle ([(0 , 0 ), (100 , 50 )], 1 )
747+ im .putpalette ((0 , 0 , 0 , 255 , 0 , 0 ))
748+
749+ im2 = Image .new ("P" , (100 , 100 ))
750+ im2 .putpalette ((0 , 0 , 0 ))
751+
752+ im .save (out , save_all = True , append_images = [im2 ], disposal = [0 , 2 ])
753+
754+ with Image .open (out ) as im :
755+ im .seek (1 )
756+ assert im .getpixel ((0 , 0 )) == (0 , 0 , 0 , 255 )
757+
758+
737759def test_transparency_in_second_frame (tmp_path : Path ) -> None :
738760 out = str (tmp_path / "temp.gif" )
739761 with Image .open ("Tests/images/different_transparency.gif" ) as im :
0 commit comments