Languages
tesseract --list-langs
List installed languages
tesseract <img> <out> -l <lang>
Recognize one language
Default is eng. Codes are three letters, e.g. deu, fra.
tesseract <img> <out> -l
<lang>+<lang>
Combine several languages
tesseract <img> <out> -l
script/<Script>
Use a script model
tesseract --tessdata-dir <dir> --list-langs
List languages in another folder
TESSDATA_PREFIX=<dir> tesseract <img>
<out>
Point to the tessdata parent
Layout (--psm)
tesseract <img> <out> --psm 3
Fully automatic layout (default)
tesseract <img> <out> --psm 6
One uniform block of text
tesseract <img> <out> --psm 7
One single text line
tesseract <img> <out> --psm 8
One single word
tesseract <img> <out> --psm 10
One single character
tesseract <img> <out> --psm 4
One column of variable sizes
tesseract <img> <out> --psm 11
Sparse text, any order
tesseract <img> <out> --psm 12
Sparse text plus orientation
tesseract <img> <out> --psm 0
Detect orientation and script only
tesseract <img> <out> --psm 1
Automatic with orientation detection
tesseract <img> <out> --psm 13
Raw line, no extra processing
Engine & tuning
tesseract <img> <out> --oem 1
Use the LSTM neural engine
tesseract <img> <out> --oem 0
Use the legacy engine
Needs traineddata files that include the legacy models.
tesseract <img> <out> --oem 2
Legacy plus LSTM
tesseract <img> <out> --dpi <n>
Set input resolution
Use when the image has no or a wrong dpi in its metadata.
tesseract <img> <out> -c
<name>=<value>
Set a parameter
-c tessedit_char_whitelist=0123456789
Digits only
-c preserve_interword_spaces=1
Keep column spacing
tesseract <img> <out> --user-words
<file>
Add a word list
tesseract <img> <out> --user-patterns
<file>
Add patterns for expected text
tesseract --print-parameters
List all -c parameters
OMP_THREAD_LIMIT=1 tesseract <img> <out>
Limit to one thread
Faster for many small images run in parallel.
tesseract <img> <out> txt
Plain text, <out>.txt (default)
tesseract <img> <out> pdf
Searchable PDF with text layer
tesseract <img> <out> hocr
hOCR HTML with word boxes
tesseract <img> <out> tsv
Tab-separated words, boxes, conf
tesseract <img> <out> alto
ALTO XML
tesseract <img> <out> page
PAGE XML
tesseract <img> <out> makebox
Character box file
tesseract <img> <out> txt pdf hocr
Write several formats at once
tesseract <img> <out> quiet
Suppress warnings and messages
tesseract <img> <out> logfile
Write debug messages to tesseract.log
Preparing images
magick <in> -colorspace Gray <out>.png
Convert to grayscale
magick <in> -resize 200% <out>.png
Enlarge small text
magick <in> -density 300 <out>.png
Set 300 dpi metadata
magick <in> -threshold 50% <out>.png
Binarize to black and white
magick <in> -deskew 40% <out>.png
Straighten a slightly tilted scan
magick <in> -trim +repage <out>.png
Cut away empty margins
pdftoppm -r 300 -png <in>.pdf <prefix>
Rasterize a PDF to pages
Tesseract reads images, not PDFs. pdftoppm is from
poppler-utils.