Do not mark L mode JPEG as 1 bit in PDF #6151
Merged
+0
−1
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Resolves #6149
When saving a PDF, the
bits
setting is different for 1 and L mode images.Pillow/src/PIL/PdfImagePlugin.py
Lines 122 to 135 in a6a843e
Except that both images are encoded as JPEGs,
Pillow/src/PIL/PdfImagePlugin.py
Lines 165 to 166 in a6a843e
which treats both 1 and L as L.
Pillow/src/PIL/JpegImagePlugin.py
Lines 574 to 578 in a6a843e
So instructing the PDF that
BitsPerComponent
is different for these two images seems wrong. As a result, 1-bit PDFs from the current version of the code are read successfully by Chrome, but not by Firefox.This PR fixes that by setting
bits
to 8 for 1-bit images as well.