Is there any way to select the text from a scanned document? (output is a jpg) What kind of tools does Ubuntu offer to do such a task? Is there any libraries I can use instead of pre-build software binaries to do the same thing? I tried converting it to a .pdf using Imagemagick and then trying to select the text, which obviously didn't worked.


The name for this type of procedure is OCR (Optical Character Recognition). That link also offers a couple of choices:

gocr - A command line OCR
fuzzyocr - spamassassin plugin to check image attachments
libhocr0 - Hebrew OCR
ocrad - Optical Character Recognition program
ocrfeeder - Document layout analysis and optical character recognition system
ocropus - document analysis and OCR system
cuneiform - multi-language OCR system 

And it suggests that Tesseract (very old tutorial) is the better option of these. So give it a try.


A while ago evaluated the various OCR packages in Ubuntu, found that Tesseract was the least bad of them (but bad enough), and wrote a wrapper script for the OCRing (since Tesseract wants obscure input formats like TIFF). Here's my ~/bin/ocr:

# usage: ocr filename.jpg
if test -z "$1"; then
    echo "usage: ocr filename.jpg [...]"
    echo "needs imagemagick and tesseract-ocr"
    echo "if tesseract fails, check if you've got tesseract-ocr-eng installed"
tmpdir="$(mktemp -d)"
for fn in "$@"; do
  convert "$fn" "$tmpdir/page.tif"
  tesseract "$tmpdir/page.tif" "$tmpdir/page" 2>&1 | grep -v '^Tesseract Open Source OCR Engine$'
  cat "$tmpdir/page.txt"
  cp -i "$tmpdir/page.txt" "${fn%.jpg}.txt"
  rm "$tmpdir/page.tif" "$tmpdir/page.txt"
rm -r "$tmpdir"

Preprocessing the images with GIMP (converting to B&W using the Threshold tool) seemed to helped a lot.

I hope things have improved since then. I've seen the name OCR Feeder in blog posts recently, I'd give it a try.


The Tesseract-ocr package is command line. If you want a program with a GUI, I use "gscan2pdf" and you can find it in the Ubuntu Software Center.

In gscan2pdf all you need to do is click the little scan icon near the top. I think it gives you two or three options, GOCR which isnt very good, and Tesseract which works admirably. Pick Tesseract and from this point you need to click the appropriate tab so you can find the resolution settings. Your best bet is 300 or even 600 and Tesseract will do well.

Poorly scanned, crooked, or old documents dont convert well. Good luck!

PS.. I keep reading that Tesseract can only read TIFF images. This isnt the case for me. I can import JPG or PNG too.

PPS... sorry for the edits! You might try OCRFeeder in the software center too. I have yet to try it though.


I'f found this, it's called Tesseract OCR, hopefully it may be of use to you.



I have Linux Mint 17.2 x32 Cinnamon. Probably these steps would work in Ubuntu 14.04 x32 too.

  1. Install Tesseract OCR sudo apt-get install -y tesseract-ocr tesseract-ocr-eng You can add other languages by installing additional packages. This screenshot is from synaptic: Tesseract language packages in Synaptic

Using Tesseract

OPTION 1 - by commandline open terminal, then go to folder where You keep image files (jpg, png) and run command:

a) to convert all image files to text

for i in *png; do b=`basename "$i" .png`; tesseract -l eng "$i" "$b" text; done

To merge all text files into one, run a command cat *.txt >> all.txt

b) to convert all image files to hocr files (open with Firefox)

for i in *png; do b=`basename "$i" .png`; tesseract -l eng "$i" "$b" hocr; done


a) Install gImageReader, and use it

sudo add-apt-repository -y ppa:sandromani/gimagereader
sudo apt-get update
sudo apt-get install -y gimagereader

b) Second application is VietOCR. Actual version is 4.0, so download VietOCR-4.0.zip

Unpack files and open VietOCR.jar by Java:

Open VietOCR by Java If You don't have Java installed, then you can install it from repository or You can install official Oracle Java 8. Steps for installing Oracle Java 8 in Ubuntu 14.04

sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update
sudo apt-get install oracle-java8-installer
sudo apt-get install oracle-java8-set-default

I recommend VietOCR, because it lets You to OCR pdf files, bulk conversion is also an option.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.