mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-11-13 05:06:49 +03:00
Update palette in quantize
This commit is contained in:
parent
21ff4114bd
commit
5b9c11b426
|
@ -38,9 +38,10 @@ class TestImageQuantize(PillowTestCase):
|
||||||
|
|
||||||
def test_rgba_quantize(self):
|
def test_rgba_quantize(self):
|
||||||
image = hopper('RGBA')
|
image = hopper('RGBA')
|
||||||
image.quantize()
|
|
||||||
self.assertRaises(ValueError, image.quantize, method=0)
|
self.assertRaises(ValueError, image.quantize, method=0)
|
||||||
|
|
||||||
|
self.assertEqual(image.quantize().convert().mode, "RGBA")
|
||||||
|
|
||||||
def test_quantize(self):
|
def test_quantize(self):
|
||||||
image = Image.open('Tests/images/caption_6_33_22.png').convert('RGB')
|
image = Image.open('Tests/images/caption_6_33_22.png').convert('RGB')
|
||||||
converted = image.quantize()
|
converted = image.quantize()
|
||||||
|
|
|
@ -1096,7 +1096,13 @@ class Image(object):
|
||||||
im = self.im.convert("P", dither, palette.im)
|
im = self.im.convert("P", dither, palette.im)
|
||||||
return self._new(im)
|
return self._new(im)
|
||||||
|
|
||||||
return self._new(self.im.quantize(colors, method, kmeans))
|
im = self._new(self.im.quantize(colors, method, kmeans))
|
||||||
|
|
||||||
|
from . import ImagePalette
|
||||||
|
mode = im.im.getpalettemode()
|
||||||
|
im.palette = ImagePalette.ImagePalette(mode, im.im.getpalette(mode, mode))
|
||||||
|
|
||||||
|
return im
|
||||||
|
|
||||||
def copy(self):
|
def copy(self):
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -1331,6 +1331,7 @@ static struct {
|
||||||
{"RGB", "BGR;5", 16, ImagingUnpackBGR15}, /* compat */
|
{"RGB", "BGR;5", 16, ImagingUnpackBGR15}, /* compat */
|
||||||
{"RGB", "RGBX", 32, copy4},
|
{"RGB", "RGBX", 32, copy4},
|
||||||
{"RGB", "RGBX;L", 32, unpackRGBAL},
|
{"RGB", "RGBX;L", 32, unpackRGBAL},
|
||||||
|
{"RGB", "RGBA;L", 32, unpackRGBAL},
|
||||||
{"RGB", "BGRX", 32, ImagingUnpackBGRX},
|
{"RGB", "BGRX", 32, ImagingUnpackBGRX},
|
||||||
{"RGB", "XRGB", 24, ImagingUnpackXRGB},
|
{"RGB", "XRGB", 24, ImagingUnpackXRGB},
|
||||||
{"RGB", "XBGR", 32, ImagingUnpackXBGR},
|
{"RGB", "XBGR", 32, ImagingUnpackXBGR},
|
||||||
|
|
Loading…
Reference in New Issue
Block a user