tetrak_ocr.imaging¶
Frame handling for multi-page raster images.
TIFF is the one raster format in SUPPORTED_EXTENSIONS that can hold more than one page, and archival TIFF frequently does — a scanned pamphlet or register often arrives as a single file with one frame per leaf.
Pillow opens such a file at frame 0 and says nothing about the rest. Every backend here loads images through Pillow, directly or indirectly, so “TIFF support” meant reading page one and silently discarding the others. That is the same failure the Claude backend already guards against with its max_tokens check: a truncated transcript is worse than a failed one, because it looks like a result and quietly corrupts everything downstream of it.
So the rule in this package is that a multi-frame image is either read in full
or refused by name. Tesseract reads it in full, page by page, exactly as it
already does for PDFs. The backends that cannot yet do so raise
MultiPageNotSupportedError, which names the file, the page count and a
backend that will read it — rather than returning page one as though that were
the document.
Functions
|
Number of pages in a raster image; 1 for ordinary single-page files. |
|
Yield every page of path as an independent image. |
|
Yield every page of a document, whether it is a PDF or a raster. |
|
Pages in a document of any supported kind, without rendering it. |
|
Split path into one single-page document per page, in a temp directory. |
|
Return |
|
Raise if path holds more than one frame. |
|
Yield page images one at a time, without holding the document in memory. |