-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Open
Description
Calling ImageOps.expand
on a image with an RGBA palette returns an image with an RGB palette.
Here's an example:
from PIL import Image, ImageOps
img = Image.new("P", (16, 16), 1)
img.putpalette((
255, 0, 0, 0, # TRANSPARENT RED
0, 0, 0, 255, # OPAQUE BLACK
), "RGBA")
framed_img = ImageOps.expand(img, 6, 0)
In this example I created an image of 16 × 16 pixels and with the second color of the palette (index 1), then I call ImageOps.expand to add a border with the first color of the palette (index 0).
I expected the second image to have a transparent border, but it is opaque:
We can easily verify that both images have palettes and the palettes have different modes in a Python REPL:
>>> img.palette.mode
'RGBA'
>>> framed_img.palette.mode
'RGB'
Metadata
Metadata
Assignees
Labels
No labels