pypdf icon indicating copy to clipboard operation
pypdf copied to clipboard

ROB: Clarify CMYK comment and detect image format from Pillow instead of guessing

Open BiswasNehaa opened this issue 5 months ago • 1 comments

This covers two of three items in #3869 (CMYK comment + LZW/ASCII85 logic ). Skipped the ICC one.

CMYK: The old comment there pointed to a closed pair with no information. Pillow only got Native CMYK Palette support in v10.1.0, pypdf supports back to 8.0 .0 so the work around stays.

LZW/ASCII85: switched to opening the image first and trusting Pillow's actual detected format, instead of guessing from the filter type ...this is what j-t-1 suggested in the issue thread. Kept the old guess as a fallback for when Pillow can't read it at all.

tested: ran the image test suite, same pass rate as before my change; checked the two real fixture PDFs that hit this code give identical output before/after.

Used Claude to help investigate the Pillow version history and verify the diff.

BiswasNehaa avatar Jun 26 '26 06:06 BiswasNehaa

Codecov Report

:x: Patch coverage is 71.42857% with 2 lines in your changes missing coverage. Please review. :white_check_mark: Project coverage is 97.84%. Comparing base (efc511b) to head (81c4851).

Files with missing lines Patch % Lines
pypdf/generic/_image_xobject.py 71.42% 2 Missing :warning:
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3902      +/-   ##
==========================================
- Coverage   97.86%   97.84%   -0.02%     
==========================================
  Files          57       57              
  Lines       10738    10740       +2     
  Branches     2006     2006              
==========================================
  Hits        10509    10509              
- Misses        127      129       +2     
  Partials      102      102              

:umbrella: View full report in Codecov by Harness.
:loudspeaker: Have feedback on the report? Share it here.

:rocket: New features to boost your workflow:
  • :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

codecov[bot] avatar Jun 26 '26 06:06 codecov[bot]