Merge pull request #5696 from radarhere/quantize_palette

This commit is contained in:
Hugo van Kemenade 2021-09-06 15:42:12 +03:00 committed by GitHub
commit 869b786db1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 1 deletions

View File

@ -63,6 +63,7 @@ def test_quantize_no_dither():
converted = image.quantize(dither=0, palette=palette)
assert_image(converted, "P", converted.size)
assert converted.palette.palette == palette.palette.palette
def test_quantize_dither_diff():

View File

@ -1130,7 +1130,9 @@ class Image:
"only RGB or L mode images can be quantized to a palette"
)
im = self.im.convert("P", dither, palette.im)
return self._new(im)
new_im = self._new(im)
new_im.palette = palette.palette.copy()
return new_im
im = self._new(self.im.quantize(colors, method, kmeans))