#1699·OCRmyPDF

[Feature]: Option to force grayscale output (contrast-preserving decolorization)

Author: jbarlow83Created Jun 11, 2026Updated Jun 11, 2026

Split from #1651.

Allow forcing color input to grayscale on output (drop color).

Archival-safety caveat: a naive luminance conversion (e.g. PIL convert('L')) can collapse distinct colors that share similar luminance, harming contrast and legibility — coloured text, highlights, stamps. Doing this properly needs a contrast-preserving decolorization algorithm (cf. cv2.decolor / Lu et al., "Real-time contrast preserving decolorization") so colours that map to similar gray stay distinguishable.

Constraint: implement this without a heavy dependency — we do not want to pull in something as large as OpenCV just for decolorization. We essentially want cv2.decolor's behaviour from a lightweight implementation (or make it an optional/plugin feature).

Current state: the rasterizer auto-selects the minimum colour depth a page needs but never forces colour→gray.