Your cart is currently empty!
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-ocrFedora:
sudo dnf install tesseractsudo pacman -S tesseractIf you need support for other languages, install the matching language packs. For example, for English:
sudo apt install tesseract-ocr-eng2. 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.pngThe convert command comes from ImageMagick, which you can install with:
sudo apt install imagemagick3. Run Tesseract From The Command Line
Once your image is ready, extracting text is as simple as:
tesseract image.png outputThis creates a file called output.txt in the same directory.
If you want the text printed directly to the terminal, use:
tesseract image.png stdout4. 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.pngConvert to grayscale:
convert image.png -colorspace Gray image_gray.pngResize if the text is tiny:
convert image.png -resize 200% image_large.pngRun 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 ocrshotRun 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 ocrfeedergImageReader
- Friendly interface
- Supports multiple languages
- Simple drag and drop workflow
Install it:
sudo apt install gimagereaderFinal 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.

Tech enthusiast and content creator passionate about making technology simple for everyone. I share practical tips, guides, and reviews on the latest in computers, software, and gadgets. Let’s explore the digital world together!
