mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-12-27 10:26:19 +03:00
Keep palette the same length
This commit is contained in:
parent
f45d2e296d
commit
aa4489c993
|
@ -830,7 +830,7 @@ class Image:
|
|||
arr = bytes(
|
||||
value for (index, value) in enumerate(arr) if index % 4 != 3
|
||||
)
|
||||
self.im.putpalette(mode, arr)
|
||||
palette_length = self.im.putpalette(mode, arr)
|
||||
self.palette.dirty = 0
|
||||
self.palette.rawmode = None
|
||||
if "transparency" in self.info:
|
||||
|
@ -841,7 +841,7 @@ class Image:
|
|||
self.palette.mode = "RGBA"
|
||||
else:
|
||||
self.palette.mode = "RGB"
|
||||
self.palette.palette = self.im.getpalette()
|
||||
self.palette.palette = self.im.getpalette()[: palette_length * 3]
|
||||
|
||||
if self.im:
|
||||
if cffi and USE_CFFI_ACCESS:
|
||||
|
|
|
@ -1663,8 +1663,7 @@ _putpalette(ImagingObject *self, PyObject *args) {
|
|||
|
||||
unpack(self->image->palette->palette, palette, palettesize * 8 / bits);
|
||||
|
||||
Py_INCREF(Py_None);
|
||||
return Py_None;
|
||||
return PyLong_FromLong(palettesize * 8 / bits);
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
|
|
Loading…
Reference in New Issue
Block a user