Skip to content

feat(ocr): decide with sillybos before any decoder opens a scan - #88

Merged
stephen-masters merged 1 commit into
mainfrom
feat/sillybos
Nov 1, 2026
Merged

stephen-masters merged 1 commit into
mainfrom
feat/sillybos

Conversation

@stephen-masters

Copy link
Copy Markdown
Contributor

Stage 1 of brief 022: Tetrak OCR takes sillybos (0.1.0 on PyPI, pinned >=0.1,<1) and imaging.open_image / check_pdf become thin calls into it. Tetrak's MAX_PIXELS, MAX_PDF_PAGES and PDF_RENDER_DPI stay as the policy's inputs, so nothing about the limits changes; InputRefusedError now carries sillybos's reasons.

Stricter in two ways, both deliberate: a scan whose extension disagrees with its contents (a JPEG called .png) is refused as "says PNG, is JPEG" rather than opened; and an oversized frame anywhere in a TIFF refuses the file at open, since the whole frame chain is checked before Pillow sees it. The _check_pixels per-frame check goes as redundant.

docs/installation.md names the check and corrects what Poppler is used for (pdfinfo before rendering, so a missing poppler now stops with a message that says to install it).

519 tests pass, 13 xfail as before. A feat: it adds a dependency and refuses files it previously opened, so 5.21.0.

🤖 Generated with Claude Code

imaging.open_image and check_pdf now delegate the deciding to sillybos,
the library that grew out of them: the format from the file's own bytes,
the header read by bounded code of its own, a PDF asked about through
pdfinfo in a separate process, and a reason in a sentence. Tetrak's
limits stay as this module's constants and become the policy. Two
things are stricter than before: a file whose extension disagrees with
its contents is refused by name, and a TIFF's every frame is checked
before Pillow opens the file rather than as each frame is reached.

Co-authored-by: Yvette Mankerian <yvettekm@gmail.com>
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Nov 1, 2026 •

Copy link
Copy Markdown

Deploying tetrak with  Cloudflare Pages  Cloudflare Pages

Latest commit: 0024650
Status: ✅  Deploy successful!
Preview URL: https://70f715a7.tetrak.pages.dev
Branch Preview URL: https://feat-sillybos.tetrak.pages.dev

View logs

@stephen-masters
stephen-masters merged commit b3d10a3 into main Nov 1, 2026
8 checks passed
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