@@ -74,10 +74,9 @@ def extract_from_ocr(pdf, pages)
7474 tiff = "#{ tempdir } /#{ @pdf_name } .tif"
7575 escaped_tiff = ESCAPE [ tiff ]
7676 run "MAGICK_TMPDIR=#{ tempdir } OMP_NUM_THREADS=2 gm convert -despeckle #{ MEMORY_ARGS } #{ OCR_FLAGS } #{ escaped_pdf } #{ escaped_tiff } 2>&1"
77- psm = "-psm 1"
78- if @nod || !DEPENDENCIES [ :osd ] #if the user says don't do orientation detection or the plugin is not installed, set psm to 0
79- psm = ""
80- end
77+ #if the user says don't do orientation detection or the plugin is not installed, set psm to 0
78+ psm = "-psm 1" if @detect_orientation and DEPENDENCIES [ :osd ]
79+ psm ||= ""
8180 run "tesseract #{ escaped_tiff } #{ base_path } -l #{ @language } #{ psm } 2>&1"
8281 clean_text ( base_path + '.txt' ) if @clean_ocr
8382 end
@@ -121,15 +120,15 @@ def extract_page(pdf, page)
121120 end
122121
123122 def extract_options ( options )
124- @output = options [ :output ] || '.'
125- @pages = options [ :pages ]
126- @force_ocr = options [ :ocr ] == true
127- @forbid_ocr = options [ :ocr ] == false
128- @clean_ocr = !( options [ :clean ] == false )
129- @language = options [ :language ] || 'eng'
130- @nod = options [ :nod ] == true
123+ @output = options [ :output ] || '.'
124+ @pages = options [ :pages ]
125+ @force_ocr = options [ :ocr ] == true
126+ @forbid_ocr = options [ :ocr ] == false
127+ @clean_ocr = !( options [ :clean ] == false )
128+ @language = options [ :language ] || 'eng'
129+ @detect_orientation = options [ :detect_orientation ] == true
131130 end
132131
133132 end
134133
135- end
134+ end
0 commit comments