Skip to content

Conversation

@radarhere
Copy link
Member

Resolves #6924

As suggested in the issue, adds RGBA saving for PDFs through the JPXDecode filter with JPEG2000 image data.

However, when opening the result, I found that the background wasn't transparent, but black instead.

Testing converting a transparent PNG to JPEG2000 (Image.open("Tests/images/transparent.png").save("transparent.jp2")), this is the case when simply saving JPEG2000 images. After looking at uclouvain/openjpeg#416 and https://github.com/uclouvain/openjpeg/blob/2d606701e8b7aa83f657d113c3367508e99bd12b/src/lib/openjp2/jp2.c#L2015-L2024 though, it turns out it was simply a case of telling OpenJPEG which channel was the alpha channel.

Copy link
Member

@hugovk hugovk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, let's add to the release notes (and regular docs if applicable).

radarhere added a commit to radarhere/Pillow that referenced this pull request Mar 12, 2023
@hugovk hugovk added the automerge Automatically merge PRs that are ready label Mar 12, 2023
@mergify mergify bot merged commit d0f3167 into python-pillow:main Mar 12, 2023
@radarhere radarhere deleted the pdf branch March 12, 2023 20:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

automerge Automatically merge PRs that are ready Enhancement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Cannot save PDF with mode RGBA

2 participants