Skip to content

Commit

Permalink
Merge pull request #5696 from radarhere/quantize_palette
Browse files Browse the repository at this point in the history
  • Loading branch information
hugovk committed Sep 6, 2021
2 parents 50d6254 + 0dba286 commit 869b786
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
1 change: 1 addition & 0 deletions Tests/test_image_quantize.py
Expand Up @@ -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():
Expand Down
4 changes: 3 additions & 1 deletion src/PIL/Image.py
Expand Up @@ -1130,7 +1130,9 @@ def quantize(self, colors=256, method=None, kmeans=0, palette=None, dither=1):
"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))

Expand Down

0 comments on commit 869b786

Please sign in to comment.