fxconv: better support for indexed images

Indexed images don't have an alpha channel, so the detection of
transparent pixels in fxconv failed. This change forces a conversion of
indexed images to RGBA to properly handle this.
This commit is contained in:
Lephenixnoir 2020-07-16 15:42:23 +02:00
parent 84f77c3136
commit 66d88bef7a
Signed by: Lephenixnoir
GPG Key ID: 1BBA026E13FC0495
1 changed files with 5 additions and 0 deletions

View File

@ -737,6 +737,11 @@ def quantize(img, dither=False):
palette.putpixel((i, 0), c)
palette = palette.convert("P")
# Make the image RGBA in case it was indexed so that transparent pixels are
# represented in an alpha channel
if img.mode == "P":
img = img.convert("RGBA")
# Save the alpha channel, and make it either full transparent or opaque
try:
alpha_channel = img.getchannel("A").convert("1", dither=Image.NONE)