mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-01-12 18:26:17 +03:00
overwrite redundant Image palette with new ImageCore Palette after quantize, fixes #513
This commit is contained in:
parent
232c175bd9
commit
6457eed2cb
|
@ -734,7 +734,10 @@ class Image:
|
|||
|
||||
if mode == "P" and palette == ADAPTIVE:
|
||||
im = self.im.quantize(colors)
|
||||
return self._new(im)
|
||||
new = self._new(im)
|
||||
from PIL import ImagePalette
|
||||
new.palette = ImagePalette.raw("RGB", new.im.getpalette("RGB"))
|
||||
return new
|
||||
|
||||
# colorspace conversion
|
||||
if dither is None:
|
||||
|
|
|
@ -505,7 +505,7 @@ def _save(im, fp, filename, chunk=putchunk, check=0):
|
|||
else:
|
||||
# check palette contents
|
||||
if im.palette:
|
||||
colors = max(len(im.im.getpalette("RGB"))//3, 256)
|
||||
colors = max(min(len(im.palette.getdata()[1])//3, 256), 2)
|
||||
else:
|
||||
colors = 256
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user