23/02/2026 - Spectacle now supports OCR natively, therefore archiving this repo.
Add quick OCR (text extraction) to screenshots you take with Spectacle.
In Spectacle select Extract or right click an image → Extract Text → the recognized text lands in your clipboard, with a desktop notification.
- 🖼️ Auto-resizes the image for better OCR accuracy
- 🧠 Tesseract OCR with multiple languages (
engby default) - 📋 Copies result straight to your clipboard (Wayland wl-copy / X11 xclip)
- 🔔 Desktop notifications for success and errors
- 🧹 Cleans up temporary files automatically
- Tesseract OCR (with language data for the languages you use)
- ImageMagick (
magickcommand) - Clipboard tool
- Wayland:
wl-clipboard(useswl-copy) - X11:
xclip
- Wayland:
- libnotify (
notify-send) - desktop-file-utils (to update the desktop database)
These are installed automatically by the setup script below.
- Download the files with either git or wget.
- cd into the folder
- Run:
bash setup.sh
- The script will:
- Detect your package manager and prompt you to install the required packages
- Ask where to install
ocr.sh(defaults to~/.local/bin) - Create
~/.local/share/applications/spectacle-ocr.desktop - Update the desktop database
After installation, you’ll have a launcher named “Extract Text” registered for PNG images.
-
Install dependencies for your distro, e.g. Ubuntu/Debian:
sudo apt-get update sudo apt-get install -y tesseract-ocr imagemagick wl-clipboard xclip libnotify-bin desktop-file-utils
(Wayland users only need
wl-clipboard; X11 users only needxclip.) -
Copy
ocr.shsomewhere in your$PATHand make it executable:install -Dm755 ./ocr.sh "$HOME/.local/bin/ocr.sh" -
Create the desktop entry:
mkdir -p ~/.local/share/applications cat > ~/.local/share/applications/spectacle-ocr.desktop <<'EOF' [Desktop Entry] Name=Extract Text Exec=sh -c "nohup $HOME/.local/bin/ocr.sh %f >/dev/null 2>&1 &" MimeType=image/png; Icon=scanner Terminal=false Type=Application Categories=Utility; StartupNotify=false EOF update-desktop-database ~/.local/share/applications || true
- Take a screenshot with Spectacle and click Export -> Extract Text.
- OR save the image and in your file manager, right-click the PNG → Open With → Extract Text.
The text is copied to your clipboard and you’ll see a notification.
ocr.sh /path/to/image.png
# Result is copied to the clipboard; notification is shown.- Languages: Change the
LANGparameter at the top of theocr.shscript to select the languages. - Examples:
- English only:
LANG="eng" - English + German:
LANG="eng+deu" - Add other Tesseract langs if installed (e.g.,
spa,fra, etc.).
- English only:
- Wayland vs X11: The script prefers
wl-copy(Wayland) and falls back toxclip(X11). - ImageMagick policies: Some distros restrict certain operations via ImageMagick’s policy file. If you hit errors, check
/etc/ImageMagick-*/policy.xml. - Input formats: The
.desktopentry registers forimage/png. ExtendMimeTypeif you want JPEG, etc.
rm -f ~/.local/share/applications/spectacle-ocr.desktop
update-desktop-database ~/.local/share/applications || true
rm -f ~/.local/bin/ocr.sh