From a594098e9be162bff2ff6988ec7be0c87eeeb888 Mon Sep 17 00:00:00 2001 From: pix666 Date: Fri, 15 Mar 2024 15:00:05 +0400 Subject: [PATCH] Preserve transparency in palette-based PNG --- pilkit/processors/utils.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/pilkit/processors/utils.py b/pilkit/processors/utils.py index a0d08ed..587ee5b 100644 --- a/pilkit/processors/utils.py +++ b/pilkit/processors/utils.py @@ -29,4 +29,9 @@ def resolve_palette(image): if image.palette is None: return image - return image.convert(image.palette.mode) \ No newline at end of file + + has_transparency = "transparency" in image.info + mode = image.palette.mode + if mode == "RGB" and has_transparency: + mode = "RGBA" + return image.convert(mode)