From a2eff2aff58e2f10ab29c982d25dad58229e1330 Mon Sep 17 00:00:00 2001 From: Andrew Murray Date: Mon, 20 Jun 2022 09:18:05 +1000 Subject: [PATCH] Added test --- Tests/test_image_quantize.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/Tests/test_image_quantize.py b/Tests/test_image_quantize.py index e9afd9118..981753eb9 100644 --- a/Tests/test_image_quantize.py +++ b/Tests/test_image_quantize.py @@ -65,6 +65,22 @@ def test_quantize_no_dither(): assert converted.palette.palette == palette.palette.palette +def test_quantize_no_dither2(): + im = Image.new("RGB", (9, 1)) + im.putdata(list((p,) * 3 for p in range(0, 36, 4))) + + palette = Image.new("P", (1, 1)) + data = (0, 0, 0, 32, 32, 32) + palette.putpalette(data) + quantized = im.quantize(dither=Image.Dither.NONE, palette=palette) + + assert tuple(quantized.palette.palette) == data + + px = quantized.load() + for x in range(9): + assert px[x, 0] == (0 if x < 5 else 1) + + def test_quantize_dither_diff(): image = hopper() with Image.open("Tests/images/caption_6_33_22.png") as palette: