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 LA images as PDFs #7299

Merged
merged 2 commits into from
Aug 4, 2023
Merged

Added saving LA images as PDFs #7299

merged 2 commits into from
Aug 4, 2023

Conversation

radarhere
Copy link
Member

Resolves #7293

This is similar to #6925, except for LA instead of RGBA, and so uses

colorspace = PdfParser.PdfName("DeviceGray")
procset = "ImageB" # grayscale

instead of
colorspace = PdfParser.PdfName("DeviceRGB")
procset = "ImageC" # color images

@@ -490,6 +490,8 @@ j2k_encode_entry(Imaging im, ImagingCodecState state) {

if (strcmp(im->mode, "RGBA") == 0) {
image->comps[3].alpha = 1;
} else if (strcmp(im->mode, "LA") == 0) {
Copy link
Member

Choose a reason for hiding this comment

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

Does it mean there was no LA support for JPEG2K at all? Do we need better testing for this case, which is not related to pdf?

Copy link
Member Author

@radarhere radarhere Jul 23, 2023

Choose a reason for hiding this comment

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

Without this change, saving an LA image as JPEG2K and visually inspecting it, shows a black rather than transparency. This fixes that. However, opening the saved image afterwards and running getpixel() gives (0, 0) either way.

When Pillow reads a JPEG2K image, it only checks the "number of components" to see if it is LA.

@hugovk hugovk merged commit 95257df into python-pillow:main Aug 4, 2023
52 of 53 checks passed
@radarhere radarhere deleted the pdf branch August 4, 2023 08:43
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.

3 participants