Skip to content

Pad COLORMAP to 768 items when saving TIFF#6232

Merged
hugovk merged 1 commit intopython-pillow:mainfrom
radarhere:colormap
Jun 1, 2022
Merged

Pad COLORMAP to 768 items when saving TIFF#6232
hugovk merged 1 commit intopython-pillow:mainfrom
radarhere:colormap

Conversation

@radarhere
Copy link
Copy Markdown
Member

@radarhere radarhere commented Apr 21, 2022

Resolves #6230

#6060 contained a commit entitled "Allow getpalette() to return less than 256 colors"

That has that meant that there are less entries in COLORMAP.

if im.mode in ["P", "PA"]:
lut = im.im.getpalette("RGB", "RGB;L")
ifd[COLORMAP] = tuple(v * 256 for v in lut)

Which then triggers the following error in the issue.

Pillow/src/encode.c

Lines 791 to 792 in c6637bc

PyErr_SetString(
PyExc_ValueError, "Requiring 768 items for Colormap");

This PR pads the COLORMAP entries until it reaches 768.

@hugovk hugovk merged commit 55d3c07 into python-pillow:main Jun 1, 2022
@radarhere radarhere deleted the colormap branch June 1, 2022 21:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Exceptions when trying to convert BMP to TIFF

2 participants