Skip to content

Simplify palette code - #10003

Open
radarhere wants to merge 1 commit into
python-pillow:mainfrom
radarhere:simplify
Open

radarhere wants to merge 1 commit into
python-pillow:mainfrom
radarhere:simplify

Conversation

@radarhere

Copy link
Copy Markdown
Member

As a consequence of #9985, data no longer needs to be converted to bytes here.

Pillow/src/PIL/Image.py

Lines 2170 to 2172 in 7e57b6c

if not isinstance(data, bytes):
data = bytes(data)
palette = ImagePalette.raw(rawmode, data)

Before #9985, this change would have caused test failures from load()

Pillow/src/PIL/Image.py

Lines 989 to 990 in 7e57b6c

mode, arr = self.palette.getdata()
self.im.putpalette(self.palette.mode, mode, arr)

But no longer.

Also, given that the default ImagePalette mode is RGB, this is unnecessary.

Pillow/src/PIL/Image.py

Lines 2179 to 2180 in 7e57b6c

else:
self.palette.mode = "RGB"

@radarhere radarhere changed the title Simplify putpalette() Simplify palette code Sep 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant