Do not use raw ImagePalette

This commit is contained in:
Andrew Murray 2021-06-27 15:09:39 +10:00
parent 59a3e3bc60
commit 450382f574
3 changed files with 5 additions and 5 deletions

View File

@ -749,10 +749,10 @@ def test_rgb_transparency(tmp_path):
# Single frame
im = Image.new("RGB", (1, 1))
im.info["transparency"] = (255, 0, 0)
pytest.warns(UserWarning, im.save, out)
im.save(out)
with Image.open(out) as reloaded:
assert "transparency" not in reloaded.info
assert "transparency" in reloaded.info
# Multiple frames
im = Image.new("RGB", (1, 1))

View File

@ -128,8 +128,8 @@ def test_trns_l(tmp_path):
assert "transparency" in im_p.info
im_p.save(f)
im_p = pytest.warns(UserWarning, im.convert, "P", palette=Image.ADAPTIVE)
assert "transparency" not in im_p.info
im_p = im.convert("P", palette=Image.ADAPTIVE)
assert "transparency" in im_p.info
im_p.save(f)

View File

@ -1016,7 +1016,7 @@ class Image:
new = self._new(im)
from . import ImagePalette
new.palette = ImagePalette.raw("RGB", new.im.getpalette("RGB"))
new.palette = ImagePalette.ImagePalette("RGB", new.im.getpalette("RGB"))
if delete_trns:
# This could possibly happen if we requantize to fewer colors.
# The transparency would be totally off in that case.