mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-01-12 18:26:17 +03:00
Merge pull request #5879 from radarhere/quantize
Limit quantized palette to number of colors
This commit is contained in:
commit
17ec8b5c98
|
@ -77,6 +77,13 @@ def test_quantize_dither_diff():
|
|||
assert dither.tobytes() != nodither.tobytes()
|
||||
|
||||
|
||||
def test_colors():
|
||||
im = hopper()
|
||||
colors = 2
|
||||
converted = im.quantize(colors)
|
||||
assert len(converted.palette.palette) == colors * len("RGB")
|
||||
|
||||
|
||||
def test_transparent_colors_equal():
|
||||
im = Image.new("RGBA", (1, 2), (0, 0, 0, 0))
|
||||
px = im.load()
|
||||
|
|
|
@ -1109,7 +1109,8 @@ class Image:
|
|||
from . import ImagePalette
|
||||
|
||||
mode = im.im.getpalettemode()
|
||||
im.palette = ImagePalette.ImagePalette(mode, im.im.getpalette(mode, mode))
|
||||
palette = im.im.getpalette(mode, mode)[: colors * len(mode)]
|
||||
im.palette = ImagePalette.ImagePalette(mode, palette)
|
||||
|
||||
return im
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user