From 42f67d184a609a6e36c6c577777144ea51e91321 Mon Sep 17 00:00:00 2001 From: Andrew Murray Date: Thu, 7 Apr 2022 08:58:57 +1000 Subject: [PATCH] Round lut values where necessary --- Tests/test_image_point.py | 1 + src/PIL/Image.py | 2 ++ 2 files changed, 3 insertions(+) diff --git a/Tests/test_image_point.py b/Tests/test_image_point.py index 366f45854..428ad116b 100644 --- a/Tests/test_image_point.py +++ b/Tests/test_image_point.py @@ -10,6 +10,7 @@ def test_sanity(): im.point(list(range(256))) im.point(list(range(256)) * 3) im.point(lambda x: x) + im.point(lambda x: x * 1.2) im = im.convert("I") with pytest.raises(ValueError): diff --git a/src/PIL/Image.py b/src/PIL/Image.py index 2e8279583..74ddca911 100644 --- a/src/PIL/Image.py +++ b/src/PIL/Image.py @@ -1720,6 +1720,8 @@ class Image: # FIXME: _imaging returns a confusing error message for this case raise ValueError("point operation not supported for this mode") + if mode != "F": + lut = [round(i) for i in lut] return self._new(self.im.point(lut, mode)) def putalpha(self, alpha):