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

BUG: Consistently apply color palettes by default #955

Merged
merged 6 commits into from
Mar 13, 2023

Conversation

FirefoxMetzger
Copy link
Contributor

xref: scikit-image/scikit-image#6764 revealed that ImageIO is not behaving consistently when decoding images that use a color palette. GIFs have their palette applied by default; however, other formats (like PNG) don't.

This is a regression from the old pillow plugin, and while paletted images that aren't GIF are fairly rare in practice, we should still behave consistently and avoid surprising behavior. Hence, this PR updates the pillow plugin to apply palettes by default. The (raw) index data can still be read by passing mode="P".

This PR also updates how the color palette is exposed as part of the metadata. (1) Since we apply a color palette by default, we should (by default) exclude it from the metadata. This PR changes that behavior and aligns the plugin to the documented API. (2) It changes the returned value from a PIL.ImagePalette.ImagePalette to a np.ndarray. This should make interacting with and inspecting the palette much easier in the future.

@FirefoxMetzger FirefoxMetzger merged commit 938de2d into imageio:master Mar 13, 2023
@FirefoxMetzger FirefoxMetzger deleted the pillow_palette_handling branch March 13, 2023 08:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant