Skip to content

Commit

Permalink
Merge pull request #74 from pix666/fix-palette-based-png
Browse files Browse the repository at this point in the history
Preserve transparency in palette-based PNG
  • Loading branch information
vstoykov authored Mar 18, 2024
2 parents 92ccef0 + a594098 commit ce84138
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion pilkit/processors/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,9 @@ def resolve_palette(image):

if image.palette is None:
return image
return image.convert(image.palette.mode)

has_transparency = "transparency" in image.info
mode = image.palette.mode
if mode == "RGB" and has_transparency:
mode = "RGBA"
return image.convert(mode)

0 comments on commit ce84138

Please sign in to comment.