Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pad COLORMAP to 768 items when saving TIFF #6232

Merged
merged 1 commit into from Jun 1, 2022

Conversation

radarhere
Copy link
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