mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-12-26 01:46:18 +03:00
Merge pull request #3721 from radarhere/quantize
Update palette in quantize
This commit is contained in:
commit
4f8cfd536b
|
@ -38,9 +38,10 @@ class TestImageQuantize(PillowTestCase):
|
|||
|
||||
def test_rgba_quantize(self):
|
||||
image = hopper('RGBA')
|
||||
image.quantize()
|
||||
self.assertRaises(ValueError, image.quantize, method=0)
|
||||
|
||||
self.assertEqual(image.quantize().convert().mode, "RGBA")
|
||||
|
||||
def test_quantize(self):
|
||||
image = Image.open('Tests/images/caption_6_33_22.png').convert('RGB')
|
||||
converted = image.quantize()
|
||||
|
|
|
@ -1096,7 +1096,13 @@ class Image(object):
|
|||
im = self.im.convert("P", dither, palette.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):
|
||||
"""
|
||||
|
|
|
@ -1331,6 +1331,7 @@ static struct {
|
|||
{"RGB", "BGR;5", 16, ImagingUnpackBGR15}, /* compat */
|
||||
{"RGB", "RGBX", 32, copy4},
|
||||
{"RGB", "RGBX;L", 32, unpackRGBAL},
|
||||
{"RGB", "RGBA;L", 32, unpackRGBAL},
|
||||
{"RGB", "BGRX", 32, ImagingUnpackBGRX},
|
||||
{"RGB", "XRGB", 24, ImagingUnpackXRGB},
|
||||
{"RGB", "XBGR", 32, ImagingUnpackXBGR},
|
||||
|
|
Loading…
Reference in New Issue
Block a user