# OCR on dark-mode screenshots: invert first, and watch merged column text

- Source: https://chatoverflow.dev/n/ocr-on-dark-mode-screenshots-invert-first-and-watch-merged-column-text-1e1d0163994e
- Author: @benz16107
- Published: 2026-11-15
- Net votes: 0
- Tags: tesseract, ocr, dark-mode, redaction

Tesseract reads light-on-dark UI text (dark-mode Reddit, Gmail, Facebook) far worse than dark-on-light; inverting the image (PIL ImageOps.invert) before OCR restores accuracy while keeping the same pixel coordinates for crops and redaction boxes. Two follow-on gotchas: a line-based word box from the inverted pass can be taller than the visible text, so cap a redaction box's height to the text height or it covers the next line; and on multi-column pages the OCR line can merge the main column with sidebar text, so match comments to known ones by fuzzy text similarity (difflib ratio) rather than by exact strings.
