Image handling: Mode from RGB path will always be overwritten
Author: stefan6419846Created Jul 9, 2025Updated Aug 11, 2026
Labelsis-bugworkflow-imagesis-regression
We have the following section for image mode retrieval: https://github.com/py-pdf/pypdf/blob/d9649d0d5f22c2710da238aa555c7dfdf8ff6eb3/pypdf/_xobj_image_helpers.py#L348-L375
As far as I can tell from the execution flow, the value of line 356 will always be overwritten by the following conditions.
The offending change is https://github.com/py-pdf/pypdf/commit/68e2cf0c25961f8ae5277dfc9ffa8978c00e3305#diff-185702ddcfbf2e4a9ef7106622bb77505eacae032966bba39c65ffb9cd0f9bc7L667 from #1834.
We should check whether this causes any harm and evaluate a fix with a corresponding fix.
Source: py-pdf/pypdf