Skip to content

Fix pillow-13 support. - #131

Open
hugobuddel wants to merge 2 commits into
ImagingDataCommons:masterfrom
hugobuddel:fix-pillow-13-support
Open

hugobuddel wants to merge 2 commits into
ImagingDataCommons:masterfrom
hugobuddel:fix-pillow-13-support

Conversation

@hugobuddel

Copy link
Copy Markdown

Pillow 13 does not allow saving a 32bit grayscale image as png: https://pillow.readthedocs.io/en/stable/releasenotes/13.0.0.html

Saving I mode images as PNG

In order to fit the 32 bits of I mode images into PNG, when PNG images can only contain at most 16 bits for a channel, Pillow has been clipping the values. Rather than quietly changing the data, this is now removed. Instead, the image can be converted to another mode before saving:

from PIL import Image
im = Image.new("I", (1, 1))
im.convert("I;16").save("out.png")

This P.R. does exactly that, and now the tests pass.

See also the critical CVE's in Pillow 12.3 that are patched in Pillow 13.

@sonarqubecloud

Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
4.1% Duplication on New Code (required ≤ 3%)

See analysis details on SonarQube Cloud

@hugobuddel

Copy link
Copy Markdown
Author

So I changed all the type hint Unions to type expression unions because SonarQube wants that, even though I didn't touch any of those lines originally. And now it complains about code duplication...

I suggest to merge just the first commit of this branch, and then do a separate pass over the entire code base fixing these other issues.

This branch has not been deployed

No deployments
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.

1 participant