TesseractOCRParser Configuration
Table of Contents
Configuration options for TesseractOCRParser, which runs the tesseract command-line program in
a separate process.
Basic Configuration
{
"parsers": [
{
"tesseract-ocr-parser": {
"language": "eng",
"timeoutMillis": 120000
}
},
{
// Keep Tika's other default parsers. Without this, only image files are OCR'd.
"default-parser": {}
}
]
}
Full Configuration
Every option with its default value and an inline comment describing it. The default-parser entry
keeps the rest of Tika’s parsers loaded — see Configuration for why
that matters. ImageMagick is optional; it is used only when enableImagePreprocessing or
applyRotation is true.
{
// A "parsers" list loads ONLY the parsers it names; the "default-parser" entry at
// the bottom keeps all the others (needed so PDFs/Office docs still reach OCR).
// Windows paths in JSON need forward slashes or escaped backslashes.
"parsers": [
{
"tesseract-ocr-parser": {
// Calculate skew and rotate (via ImageMagick) before OCR. Needs ImageMagick.
"applyRotation": false,
// Colorspace of the preprocessed image (preprocessing only).
"colorspace": "gray",
// Resolution (dpi) of the preprocessed image.
"density": 300,
// Bits per color sample in the preprocessed image.
"depth": 4,
// Run ImageMagick preprocessing (density/depth/colorspace/filter/resize) before OCR.
"enableImagePreprocessing": false,
// ImageMagick resize filter.
"filter": "triangle",
// Directory holding the ImageMagick program (empty = on PATH). ImageMagick is
// OPTIONAL -- used only when enableImagePreprocessing or applyRotation is true.
"imageMagickPath": "",
// Write OCR output from embedded images inline into the parent document.
"inlineContent": false,
// Tesseract language(s); join multiple with '+', e.g. "eng+fra".
"language": "eng",
// Skip OCR for files larger than this many bytes.
"maxFileSizeToOcr": 2147483647,
// Skip OCR for files smaller than this many bytes.
"minFileSizeToOcr": 0,
// Additional raw Tesseract config variables (key-value).
"otherTesseractConfig": {
"preserve_interword_spaces": "1",
"textord_initialx_ile": "0.75",
"textord_noise_hfract": "0.15625"
},
// Tesseract output format.
// Options: TXT, HOCR
"outputType": "TXT",
// Inserted between OCR'd pages (empty overrides Tesseract 4's form-feed).
"pageSeparator": "",
// Page segmentation mode (0-13); 1 = auto with orientation/script detection.
"pageSegMode": "1",
// Load Tesseract language data at startup instead of on first use.
"preloadLangs": false,
// Preserve interword spacing in the output.
"preserveInterwordSpacing": false,
// Scale percent (100-900) applied during preprocessing.
"resize": 200,
// Runtime kill-switch to disable OCR.
"skipOcr": false,
// Directory with tessdata language files (empty = Tesseract default).
"tessdataPath": "",
// Directory with the tesseract binary (empty = on PATH).
"tesseractPath": "",
// Max seconds to wait for the OCR process.
"timeoutMillis": 120000
}
},
{
// Keep Tika's other default parsers. Without this, only image files are OCR'd.
"default-parser": {}
}
]
}
Arbitrary Tesseract variables go in otherTesseractConfig as a name-to-value map, as in the
example above. Converting a 3.x config? See
Migrating to 4.x — the automatic converter rewrites the
old otherTesseractSettings list for you.