Skip to content

fix(ocr): encode non-PNG color modes for Google Vision - #4828

Draft
Afloat16 wants to merge 1 commit into
Unstructured-IO:mainfrom
Afloat16:Afloat16/google-vision-image-modes-20261121
Draft

Afloat16 wants to merge 1 commit into
Unstructured-IO:mainfrom
Afloat16:Afloat16/google-vision-image-modes-20261121

Conversation

@Afloat16

@Afloat16 Afloat16 commented Nov 21, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Google Vision request preparation saves every input image as PNG. Pillow cannot encode CMYK, RGBX, YCbCr or HSV directly, so these inputs fail before reaching the OCR service.

Centralize PNG encoding and convert those color modes through a temporary RGB image. Leave native PNG modes unchanged and preserve the caller's image and language hints. The text, region and layout-element paths all use the same encoder.

Validation

Twelve color-mode cases fail on main, with nine native-PNG controls already passing. All 21 tests pass after the change, decoding actual outgoing PNG bytes and comparing pixels, dimensions, alpha, input ownership and language hints. Whole-repository Ruff 0.15.10 lint and format checks pass. Full repository tests remain pending, so this is a draft.

When rebasing on the single-request Google Vision change, use the shared PNG encoder in its central request helper.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant