Copy palette to new image in transform()

This commit is contained in:
Andrew Murray 2021-07-30 20:11:05 +10:00
parent eee0953bb3
commit d1815377b8
2 changed files with 7 additions and 0 deletions

View File

@ -32,6 +32,11 @@ class TestImageTransform:
new_im = im.transform((100, 100), transform)
assert new_im.info["comment"] == comment
def test_palette(self):
with Image.open("Tests/images/hopper.gif") as im:
transformed = im.transform(im.size, Image.AFFINE, [1, 0, 0, 0, 1, 0])
assert im.palette.palette == transformed.palette.palette
def test_extent(self):
im = hopper("RGB")
(w, h) = im.size

View File

@ -2479,6 +2479,8 @@ class Image:
raise ValueError("missing method data")
im = new(self.mode, size, fillcolor)
if self.mode == "P" and self.palette:
im.palette = self.palette.copy()
im.info = self.info.copy()
if method == MESH:
# list of quads