From 1fb1bec0e80084aa675d7a8fd3e1d0525fe1cc06 Mon Sep 17 00:00:00 2001 From: Andrew Murray Date: Mon, 29 Nov 2021 15:12:24 +1100 Subject: [PATCH] Added test --- Tests/images/dispose_bgnd_rgba.gif | Bin 0 -> 1450 bytes Tests/test_file_gif.py | 26 ++++++++++++++++++++++++++ 2 files changed, 26 insertions(+) create mode 100644 Tests/images/dispose_bgnd_rgba.gif diff --git a/Tests/images/dispose_bgnd_rgba.gif b/Tests/images/dispose_bgnd_rgba.gif new file mode 100644 index 0000000000000000000000000000000000000000..c18a0ba71f1abf98b1bbd212dc55577255c79bc6 GIT binary patch literal 1450 zcmYk*dpOg390%~62GBX5oue1U_A1tz!r@Ujn+no+zYwJuV)B_ znV}s`@cU;ti8XCXi#g1>=mUS5bxv5ueW_~PlHd-a6}i5XX~oO#{Y2t>s0Xqp_$OoI zUrl2Sp4Q0PGE?GNhyap6iO8e74*8TFNYDb5$x{a z=Wi3h%Et{HU;8CKaN&d>dF3_oL(Xxt9tNv>LduQ6^wwUCbTX_enL$lg7CB&ZOwUixc()pKms!LXjT;ss!Ml$w|sSzW#S{PEqr z3!tCnzPq>fYI_aeE$}*yXUBP9L>V#P;l}_PYBWSJosG{CW*2Zt6SWi82L^3n@sCNyYbIK&yK8-9us$r?T19uJX!JbXToDqi8^WWZx zCB>0#@RC?_GEsv9kZzwz?2FfhP?CEq%fFTp5bl$No}LemV*OTetgvWBM0!}awL zD+mDTWHus?tGaC^I@#B3c} zkK%+UwZM3P!oz%;o~EAHPQ1gYk}&uTsynD!VZqI5Y3IdWR;G9i%G#|iG&n3oqJsp& zkN6~QIagCBKY}Sm(G_hN7am}(XcG}fD{_R#66J#miOAUKE9S8V1>x505S$%c9+zZ@ zi&npSHZL*jUU^5mj-*mcVQH@uF0Xi?_ZK&-3&SJM-kF2a2@Ve@`YtG-#-`a;71Pod z#Koo8ovVT??xEEJ_XSAzQsA#}*#8b@0Omgj(f>u$`VB#?x%OLJ#CAjuW|vgxtvg3ml3tIHsek?H7Be zr%ahi?;NfhAl;|-)pm_&FdvTchxU(75~m3Lsk6w@<;U~BgZjL=T%WezSevdgjx#R{ z99ITeUZ`Y;6d&kjjt@=h#rimrd$qqUL!M*gN(X%x8cE>vSFGfJ;=J+=IbYR*!;5E9;%?d-y;vN=!cWOYPXYS#y(fUpXR7Vnet!Lr^(OCP4SWuxu* z6S(fAzr$ia9~*=Z`uzg5eM9pDLlYPD zOdG21V}vq(F;h($ literal 0 HcmV?d00001 diff --git a/Tests/test_file_gif.py b/Tests/test_file_gif.py index 497cc5ed3..13eb06897 100644 --- a/Tests/test_file_gif.py +++ b/Tests/test_file_gif.py @@ -163,6 +163,32 @@ def test_roundtrip_save_all(tmp_path): assert reread.n_frames == 5 +@pytest.mark.parametrize( + "path, mode", + ( + ("Tests/images/dispose_bgnd.gif", "RGB"), + # Hexeditted copy of dispose_bgnd to add transparency + ("Tests/images/dispose_bgnd_rgba.gif", "RGBA"), + ), +) +def test_loading_multiple_palettes(path, mode): + with Image.open(path) as im: + assert im.mode == "P" + first_frame_colors = im.palette.colors.keys() + original_color = im.convert("RGB").load()[0, 0] + + im.seek(1) + assert im.mode == mode + if mode == "RGBA": + im = im.convert("RGB") + + # Check a color only from the old palette + assert im.load()[0, 0] == original_color + + # Check a color from the new palette + assert im.load()[24, 24] not in first_frame_colors + + def test_headers_saving_for_animated_gifs(tmp_path): important_headers = ["background", "version", "duration", "loop"] # Multiframe image