mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-02-03 13:14:27 +03:00
Copy Python palette to new image in quantize()
This commit is contained in:
parent
d50052a75c
commit
0dba28613b
|
@ -63,6 +63,7 @@ def test_quantize_no_dither():
|
||||||
|
|
||||||
converted = image.quantize(dither=0, palette=palette)
|
converted = image.quantize(dither=0, palette=palette)
|
||||||
assert_image(converted, "P", converted.size)
|
assert_image(converted, "P", converted.size)
|
||||||
|
assert converted.palette.palette == palette.palette.palette
|
||||||
|
|
||||||
|
|
||||||
def test_quantize_dither_diff():
|
def test_quantize_dither_diff():
|
||||||
|
|
|
@ -1130,7 +1130,9 @@ class Image:
|
||||||
"only RGB or L mode images can be quantized to a palette"
|
"only RGB or L mode images can be quantized to a palette"
|
||||||
)
|
)
|
||||||
im = self.im.convert("P", dither, palette.im)
|
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))
|
im = self._new(self.im.quantize(colors, method, kmeans))
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user