Skip to content

A fast, helpful, and open-source document parser

Honor OCR rotation option in Tesseract engine

Max Headley4fdf3c9358c2
diff --git a/.changeset/tame-mirrors-bake.md b/.changeset/tame-mirrors-bake.md
new file mode 100644
index 0000000..8255808
--- /dev/null
+++ b/.changeset/tame-mirrors-bake.md
@@ -0,0 +1,5 @@
+---
+"@llamaindex/liteparse": patch
+---
+
+Honor the OCR rotation-correction option in the built-in Tesseract engine by mapping it to Tesseract.js auto-rotation.
diff --git a/src/engines/ocr/tesseract.ts b/src/engines/ocr/tesseract.ts
index 87b7abd..ca344c1 100644
--- a/src/engines/ocr/tesseract.ts
+++ b/src/engines/ocr/tesseract.ts
@@ -117,7 +117,12 @@ export class TesseractEngine implements OcrEngine {
// In tesseract.js v6+, we need to enable blocks output to get word-level data
const {
data: { blocks },
- } = await this.scheduler.addJob("recognize", image, {}, { blocks: true });
+ } = await this.scheduler.addJob(
+ "recognize",
+ image,
+ options.correctRotation ? { rotateAuto: true } : {},
+ { blocks: true }
+ );
// Extract words from hierarchical blocks structure: blocks → paragraphs → lines → words
const results: OcrResult[] = [];