diff --git a/PIL/ImagePalette.py b/PIL/ImagePalette.py index ee3c22544..67bf593e6 100644 --- a/PIL/ImagePalette.py +++ b/PIL/ImagePalette.py @@ -134,7 +134,7 @@ def _make_linear_lut(black, white): return lut -def _make_gamma_lut(exp, mode="RGB"): +def make_gamma_lut(exp): lut = [] for i in range(256): lut.append(int(((i / 255.0) ** exp) * 255.0 + 0.5)) diff --git a/Tests/test_imagepalette.py b/Tests/test_imagepalette.py index be82f4dcb..af742edd1 100644 --- a/Tests/test_imagepalette.py +++ b/Tests/test_imagepalette.py @@ -44,6 +44,25 @@ class TestImagePalette(PillowTestCase): self.assertIsInstance(p, ImagePalette) self.assertEqual(p.palette, palette.tobytes()) + def test_make_gamma_lut(self): + # Arrange + from PIL.ImagePalette import make_gamma_lut + exp = 5 + + # Act + lut = make_gamma_lut(exp) + + # Assert + self.assertIsInstance(lut, list) + self.assertEqual(len(lut), 256) + # Check a few values + self.assertEqual(lut[0], 0) + self.assertEqual(lut[63], 0) + self.assertEqual(lut[127], 8) + self.assertEqual(lut[191], 60) + self.assertEqual(lut[255], 255) + + if __name__ == '__main__': unittest.main()