Browse Source

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.
master
Lephenixnoir 2 months ago
parent
commit
66d88bef7a
Signed by: Lephenixnoir <sebastien.michelland@protonmail.com> GPG Key ID: 1BBA026E13FC0495
1 changed files with 5 additions and 0 deletions
  1. +5
    -0
      fxconv/fxconv.py

+ 5
- 0
fxconv/fxconv.py 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)


Loading…
Cancel
Save