Skip to content

Commit

Permalink
Merge pull request #5634 from radarhere/putpalette
Browse files Browse the repository at this point in the history
putpalette() rawmode may be modes that can be unpacked to RGB
  • Loading branch information
hugovk committed Aug 13, 2021
2 parents 3d35e54 + 89ab20f commit ea4263c
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions src/PIL/Image.py
Original file line number Diff line number Diff line change
Expand Up @@ -1753,14 +1753,19 @@ def putpalette(self, data, rawmode="RGB"):
Attaches a palette to this image. The image must be a "P", "PA", "L"
or "LA" image.
The palette sequence must contain at most 768 integer values, or 1024
integer values if alpha is included. Each group of values represents
the red, green, blue (and alpha if included) values for the
corresponding pixel index. Instead of an integer sequence, you can use
an 8-bit string.
The palette sequence must contain at most 256 colors, made up of one
integer value for each channel in the raw mode.
For example, if the raw mode is "RGB", then it can contain at most 768
values, made up of red, green and blue values for the corresponding pixel
index in the 256 colors.
If the raw mode is "RGBA", then it can contain at most 1024 values,
containing red, green, blue and alpha values.
Alternatively, an 8-bit string may be used instead of an integer sequence.
:param data: A palette sequence (either a list or a string).
:param rawmode: The raw mode of the palette.
:param rawmode: The raw mode of the palette. Either "RGB", "RGBA", or a
mode that can be transformed to "RGB" (e.g. "R", "BGR;15", "RGBA;L").
"""
from . import ImagePalette

Expand Down

0 comments on commit ea4263c

Please sign in to comment.