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
No known key found for this signature in database
GPG key ID: 1BBA026E13FC0495

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)