Repository navigation
ROB: Detect LZW/ASCII85 image format via Pillow and correct image comments - #3902
Open
BiswasNehaa wants to merge 1 commit into
Open
BiswasNehaa wants to merge 1 commit into
BiswasNehaa wants to merge 1 commit into
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #3902 +/- ##
=======================================
Coverage 98.65% 98.65%
=======================================
Files 59 59
Lines 11964 11972 +8
Branches 2271 2272 +1
=======================================
+ Hits 11803 11811 +8
Misses 84 84
Partials 77 77 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
BiswasNehaa
force-pushed
the
fix-3869-image-xobject-comments
branch
from
June 26, 2026 06:47
6f2f50c to
81c4851
Compare
stefan6419846
requested changes
Aug 3, 2026
stefan6419846
requested changes
Aug 11, 2026
BiswasNehaa
force-pushed
the
fix-3869-image-xobject-comments
branch
from
October 15, 2026 17:55
6bd2c99 to
ae1cbb9
Compare
BiswasNehaa
force-pushed
the
fix-3869-image-xobject-comments
branch
from
October 15, 2026 19:34
ae1cbb9 to
8f4171b
Compare
stefan6419846
requested changes
Oct 19, 2026
BiswasNehaa
force-pushed
the
fix-3869-image-xobject-comments
branch
from
November 1, 2026 17:33
d9739de to
1f791d9
Compare
Author
|
Thanks for the review, and sorry for the delay. Both comments are addressed:
I also rebased onto the current |
This branch has not been deployed
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.
Closes #3869
This addresses the three points of the issue.
CMYK palette workaround (comment only)
The question was whether Pillow can process CMYK palettes by now, so that the workaround can go. It can partly, but not reliably:
putpalette(..., rawmode="CMYK")converts the palette to RGB. The result differs from the manual conversion by at most 1 per channel (Pillow rounds, the workaround truncates).convert("RGB")no longer converts it, so the colors are wrong (tests/test_filters.py::test_index_lookupfails with similarity 0.49 when the workaround is removed).So the workaround is still needed and stays. The comment now explains this and lists the versions checked (10.4.0, 11.0.0 - 11.3.0, 12.0.0 - 12.3.0), as suggested in the issue. The unrelated
Pillow>=8.0.0requirement is unchanged.ICC comment
Checked the behaviour instead of just rewording it: in the
/ICCBasedbranch,modeanddataare not changed afterimghas been created, so the reload (Image.frombytes(mode, size, data)) produces an identical image. The old comment (loads "with a different color space") was therefore inaccurate. I corrected the comment and kept the TODO about actually applying the ICC profile. The behaviour is unchanged; the redundant reload could be removed in a follow-up if wanted.LZW / ASCII85 image format
The format is now taken from
img.formatas detected by Pillow, instead of assuming TIFF for LZW and PNG for ASCII85. The filter-based guess is only kept for data without a TIFF/PNG container, which is interpreted as raw samples (unchanged behaviour). The raw-sample fallback keeps using_expand_low_bit_samples; an earlier revision of this PR had accidentally dropped that call, which is why the fallback lines were reported as uncovered.Behaviour change: a PNG container with the LZW filter is now reported as
.png(previously.tiff), and a TIFF container with the ASCII85 filter as.tiff(previously.png).Tests
test_xobj_to_image__lzw_ascii85_image_formatcovers raw data and real PNG/TIFF containers for both filters, including the fallback branch. The two mislabelled cases fail on currentmain.test_handle_flate__indexed_cmyk_palettechecks the exact converted palette, so it fails on any Pillow version where the palette would not be converted.