Skip to content

Commit

Permalink
Removed requirement for 256 palette entries
Browse files Browse the repository at this point in the history
  • Loading branch information
radarhere committed Aug 28, 2022
1 parent ad7be55 commit 9fa4219
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 5 deletions.
1 change: 1 addition & 0 deletions Tests/test_image.py
Expand Up @@ -620,6 +620,7 @@ def test_remap_palette_transparency(self):

im_remapped = im.remap_palette([1, 0])
assert im_remapped.info["transparency"] == 1
assert len(im_remapped.getpalette()) == 6

# Test unused transparency
im.info["transparency"] = 2
Expand Down
6 changes: 1 addition & 5 deletions src/PIL/Image.py
Expand Up @@ -1944,11 +1944,7 @@ def remap_palette(self, dest_map, source_palette=None):

m_im = m_im.convert("L")

# Internally, we require 256 palette entries.
new_palette_bytes = (
palette_bytes + ((256 * bands) - len(palette_bytes)) * b"\x00"
)
m_im.putpalette(new_palette_bytes, palette_mode)
m_im.putpalette(palette_bytes, palette_mode)
m_im.palette = ImagePalette.ImagePalette(palette_mode, palette=palette_bytes)

if "transparency" in self.info:
Expand Down

0 comments on commit 9fa4219

Please sign in to comment.