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

Added saving RGBA images as PDFs #6925

Merged
merged 5 commits into from
Mar 12, 2023
Merged

Added saving RGBA images as PDFs #6925

merged 5 commits into from
Mar 12, 2023

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