Repository navigation
BUG: Expand low-bit samples for images without a filter - #3938
Merged
Merged
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #3938 +/- ##
=======================================
Coverage 97.88% 97.88%
=======================================
Files 57 57
Lines 10813 10816 +3
Branches 2025 2025
=======================================
+ Hits 10584 10587 +3
Misses 127 127
Partials 102 102 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
stefan6419846
approved these changes
Aug 5, 2026
stefan6419846
left a comment
Collaborator
There was a problem hiding this comment.
Thanks. I just did a quick test with my example, and it is working correctly now and the output looks correct as well.
stefan6419846
added a commit
that referenced
this pull request
Aug 6, 2026
## What's new ### Security (SEC) - Improve performance of read_until_whitespace (#3947) by @stefan6419846 - Limit CID width range and width count when loading fonts (#3946) by @stefan6419846 - Limit token length for ToUnicode entries (#3944) by @stefan6419846 ### Deprecations (DEP) - Deprecate previously missed inline_images setter as well (#3897) by @stefan6419846 ### New Features (ENH) - Add ActualText tag when we produce RTL appearance stream (#3901) by @PJBrs - Allow keeping original PDF header in non-incremental clone mode (#3918) by @pctablet505 - AppearanceStream: Add support for RTL appearance streams with Arabic characters (#3831) by @PJBrs - Add actions base class (#3552) by @j-t-1 ### Bug Fixes (BUG) - Expand low-bit samples for images without a filter (#3938) by @RavSinghChandan - Decode low-bit DeviceRGB images as RGB instead of palette (#3929) by @RavSinghChandan - Correctly handle IndirectObject in FlateDecode.decode DecodeParms (#3937) by @stefan6419846 ### Documentation (DOC) - Image and attachment filenames are unsanitized (#3942) by @stefan6419846 ### Maintenance (MAINT) - Update charset mappings (#3935) by @stefan6419846 [Full Changelog](6.14.2...6.15.0)
3 tasks done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Follow-up to #3929, which only fixed the FlateDecode path.
Fixes #3367.
The 2/4-bit expansion lived inside _handle_flate, so it only ran for
FlateDecode/RunLengthDecode images. Anything else — an image with no filter
at all, or the LZW/ASCII85 fallback — passed the raw "2bits"/"4bits" mode
straight to Pillow and raised "unrecognized image mode".
Pulled the expansion out into _expand_low_bit_samples() and called it from
the three places that build an image from raw bytes. The Flate path behaves
exactly as before, bits2byte is unchanged.
Added a test that builds an uncompressed 4-bit /DeviceRGB image and checks
it decodes to RGB — it fails on main with the same ValueError you were
seeing.