mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-06-05 05:33:10 +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:
|
if mode == "P" and palette == ADAPTIVE:
|
||||||
im = self.im.quantize(colors)
|
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
|
# colorspace conversion
|
||||||
if dither is None:
|
if dither is None:
|
||||||
|
|
|
@ -505,7 +505,7 @@ def _save(im, fp, filename, chunk=putchunk, check=0):
|
||||||
else:
|
else:
|
||||||
# check palette contents
|
# check palette contents
|
||||||
if im.palette:
|
if im.palette:
|
||||||
colors = max(len(im.im.getpalette("RGB"))//3, 256)
|
colors = max(min(len(im.palette.getdata()[1])//3, 256), 2)
|
||||||
else:
|
else:
|
||||||
colors = 256
|
colors = 256
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user