RackNerd Billboard Banner

How To Extract Text From Screenshots And Images In Linux

Pulling text out of an image feels like a small superpower. You grab a screenshot, run a simple command, and suddenly the words inside it become searchable and editable. On Linux, this is easy thanks to a few reliable tools that handle OCR (optical character recognition) fast and well.

Below is a straightforward guide on how to extract text from screenshots and images on any Linux system.


1. Install Tesseract OCR

Tesseract is the tool that does the heavy lifting. It is open source and works across distros.

Ubuntu and Debian:

sudo apt update
sudo apt install tesseract-ocr

Fedora:

sudo dnf install tesseract

Arch Linux:

sudo pacman -S tesseract

If you need support for other languages, install the matching language packs. For example, for English:

sudo apt install tesseract-ocr-eng

2. Convert Your Image If Needed

Tesseract works best with PNG and JPG. Most screenshots already use one of those formats. If you have a PDF or something unusual, convert it first.

convert input.pdf output.png

The convert command comes from ImageMagick, which you can install with:

sudo apt install imagemagick

3. Run Tesseract From The Command Line

Once your image is ready, extracting text is as simple as:

tesseract image.png output

This creates a file called output.txt in the same directory.

If you want the text printed directly to the terminal, use:

tesseract image.png stdout

4. Improve Accuracy With Preprocessing

Good OCR depends on a clean image. A few tricks help Tesseract read things more accurately:

Increase contrast:

convert image.png -contrast-stretch 0 image_clean.png

Convert to grayscale:

convert image.png -colorspace Gray image_gray.png

Resize if the text is tiny:

convert image.png -resize 200% image_large.png

Run Tesseract again on the cleaned-up file.


5. Extract Text From Screenshots Automatically

If you take a lot of screenshots, create a tiny script that does everything in one step.

Example script:

#!/bin/bash
shot=$(mktemp /tmp/ocrshotXXXX.png)
text=$(mktemp /tmp/ocrtextXXXX.txt)

gnome-screenshot -a -f "$shot"
tesseract "$shot" "$text" >/dev/null 2>&1

cat "$text.txt"

Save it as ocrshot, make it executable:

chmod +x ocrshot

Run it whenever you need to grab text quickly. It prompts you to draw a rectangle, captures it, and shows you the extracted text.


6. Use GUI Tools If You Prefer A Visual Workflow

If you want something less command line heavy, a few graphical apps can help.

OCRFeeder

  • Scans images and PDFs
  • Lets you edit the recognized text
  • Good for documents

Install it on Ubuntu:

sudo apt install ocrfeeder

gImageReader

  • Friendly interface
  • Supports multiple languages
  • Simple drag and drop workflow

Install it:

sudo apt install gimagereader

Final Thoughts

Extracting text from images on Linux is quick once you have the right tools. Tesseract handles the core job, ImageMagick helps clean things up, and GUI options make the process accessible for anyone who prefers a visual approach. With this setup, screenshots and scanned documents stop being locked away as pixels and become useful, editable text.

0 0 votes
Article Rating
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments
RackNerd Billboard Banner
© 2025 Computer Everywhere
Your Everyday Guide to the Digital World.
Terms of Service | Privacy Policy
Copy link