TEXT2IMAGE(1)

πŸ’… TEXT2IMAGE(1) β€” the text2image manual page, bestie edition πŸŽ€

okay so real talk: this is the manual page for text2image, and yes we're gonna get through all of it together, no skimming, no "eh I'll figure it out later" ✨

🌸 NAME 🌸

text2image β€” generates OCR training pages. that's the whole vibe. it makes pages. for training. OCR. slay.

πŸ¦‹ SYNOPSIS πŸ¦‹

text2image --text FILE --outputbase PATH --fonts_dir PATH [OPTION]

three things you basically gotta give it: a text file, an output base, and where the fonts live. the [OPTION] part is where you go feral, and honestly there's a lot of room to go feral. πŸ’…

✨ DESCRIPTION ✨

so text2image(1) generates OCR training pages. like, that's its whole job, and it's very good at it. you hand it a text file, it hands you back an image β€” with a font you picked and degradation applied. synthetic training data, homemade, fresh out the oven. πŸ“

πŸ”₯ OPTIONS πŸ”₯

  • --text FILE β€” file name of text input to use for creating synthetic training data. (type:string default:)
  • --outputbase FILE β€” basename for output image/box file. this is the name-stem everything gets built off of. (type:string default:)
  • --fontconfig_tmpdir PATH β€” overrides fontconfig default temporary dir. (type:string default: /tmp )
  • --fonts_dir PATH β€” if empty it uses the system default. otherwise it overrides the system default font location. (type:string default:)
  • --font FONTNAME β€” font description name to use. (type:string default: Arial )
  • --writing_mode MODE β€” specify one of the following writing modes. horizontal : render regular horizontal text. (default) vertical : render vertical text. glyph orientation is selected by Pango. vertical-upright : render vertical text. glyph orientation is set to be upright. (type:string default: horizontal )
  • --tlog_level INT β€” minimum logging level for tlog() output. (type:int default: 0 )
  • --max_pages INT β€” maximum number of pages to output (0=unlimited). (type:int default: 0 )
  • --degrade_image BOOL β€” degrade rendered image with speckle noise, dilation/erosion and rotation. mess it up on purpose, that's the point πŸ’€ (type:bool default: true )
  • --rotate_image BOOL β€” rotate the image in a random way. (type:bool default: true )
  • --strip_unrenderable_words BOOL β€” remove unrenderable words from source text. (type:bool default: true )
  • --ligatures BOOL β€” rebuild and render ligatures. (type:bool default: false )
  • --exposure INT β€” exposure level in photocopier. (type:int default: 0 )
  • --resolution INT β€” pixels per inch. (type:int default: 300 )
  • --xsize INT β€” width of output image. (type:int default: 3600 )
  • --ysize INT β€” height of output image. (type:int default: 4800 )
  • --margin INT β€” margin round edges of image. (type:int default: 100 )
  • --ptsize INT β€” size of printed text. (type:int default: 12 )
  • --leading INT β€” inter-line space (in pixels). (type:int default: 12 )
  • --box_padding INT β€” padding around produced bounding boxes. (type:int default: 0 )
  • --char_spacing DOUBLE β€” inter-character space in ems. (type:double default: 0 )
  • --underline_start_prob DOUBLE β€” fraction of words to underline (value in [0,1]). (type:double default: 0 )
  • --underline_continuation_prob DOUBLE β€” fraction of words to underline (value in [0,1]). (type:double default: 0 )
  • --render_ngrams BOOL β€” put each space-separated entity from the input file into one bounding box. the ngrams in the input file will be randomly permuted before rendering (so that there is sufficient variety of characters on each line). (type:bool default: false )
  • --output_word_boxes BOOL β€” output word bounding boxes instead of character boxes. this is used for Cube training, and implied by --render_ngrams. (type:bool default: false )
  • --unicharset_file FILE β€” file with characters in the unicharset. if --render_ngrams is true and --unicharset_file is specified, ngrams with characters that are not in unicharset will be omitted. (type:string default:)
  • --bidirectional_rotation BOOL β€” rotate the generated characters both ways. (type:bool default: false )
  • --only_extract_font_properties BOOL β€” assumes that the input file contains a list of ngrams. renders each ngram, extracts spacing properties and records them in output_base/[font_name].fontinfo file. (type:bool default: false )

🫢 USE THESE FLAGS TO OUTPUT ZERO-PADDED, SQUARE INDIVIDUAL CHARACTER IMAGES 🫢

like the heading says β€” these three are the glow-up squad for solo character portraits. literal main character energy per glyph πŸ‘‘

  • --output_individual_glyph_images BOOL β€” if true also outputs individual character images. (type:bool default: false )
  • --glyph_resized_size INT β€” each glyph is square with this side length in pixels. (type:int default: 0 )
  • --glyph_num_border_pixels_to_pad INT β€” Final_size=glyph_resized_size+2*glyph_num_border_pixels_to_pad. (type:int default: 0 )

🧚 USE THESE FLAGS TO FIND FONTS THAT CAN RENDER A GIVEN TEXT 🧚

font shopping spree time. these let you hunt down every font that can actually handle your text, no cap.

  • --find_fonts BOOL β€” search for all fonts that can render the text. (type:bool default: false )
  • --render_per_font BOOL β€” if find_fonts==true, render each font to its own image. image filenames are of the form output_name.font_name.tif. (type:bool default: true )
  • --min_coverage DOUBLE β€” if find_fonts==true, the minimum coverage the font has of the characters in the text file to include it, between 0 and 1. (type:double default: 1 )

🌈 Example Usage 🌈

this is the actual example, bestie, and it is iconic β€” piping straight into grep and sed like a flex:

text2image --find_fonts \
--fonts_dir /usr/share/fonts \
--text ../langdata/hin/hin.training_text \
--min_coverage .9  \
--render_per_font \
--outputbase ../langdata/hin/hin \
|& grep raw | sed -e 's/ :.*/" \\/g'  | sed -e 's/^/  "/' >../langdata/hin/fontslist.txt

⭐ SINGLE OPTIONS ⭐

one option. just the one. she's solo and she's thriving.

  • --list_available_fonts BOOL β€” list available fonts and quit. (type:bool default: false )

πŸŽ€ HISTORY πŸŽ€

text2image(1) was first made available for tesseract 3.03. a true vintage queen, honestly. πŸ’œ

πŸ¦‹ RESOURCES πŸ¦‹

πŸ‘€ SEE ALSO πŸ‘€

tesseract(1) β€” go say hi to her too 🫢

πŸ’– COPYING πŸ’–

Copyright (C) 2012 Google, Inc. Licensed under the Apache License, Version 2.0

πŸ‘‘ AUTHOR πŸ‘‘

The Tesseract OCR engine was written by Ray Smith and his research groups at Hewlett Packard (1985-1995) and Google (2006-2018). legends, fr fr.


and that's the whole page!! this little time capsule is stamped 2026-09-28 and it'll always be filed under TEXT2IMAGE(1) β€” so if you ever forget any of it, just look at the footer of your heart (or, y'know, run the man page again 😭). mwah πŸ’‹

πŸ“¦ where this page comes from