Duncan Wither

Home Notes Github LinkedIn

Screenshot OCR

Written: 24-May-2021

Inspired by macOCR(and in particular the beautiful gif), but I wanted, no needed it for linux.

My thoughts were to use:

import is a handy function. This is how to get it to print to stdout (in .png format):

import png:-

The following command takes an image image.png and outputs text to stdout.

tesseract tess_test.png - quiet

This can then be put to the clipboard using:

xclip -sel clip

To combine the lot:

import png:- | tesseract - - quiet | xclip -sel clip

The next step (if you want) is to bind it to a shortcut. My choice is Ctl + T for text 😁 Ctl + y2.

After working all of this out someone had commented on the HN thread with this exact solution to my problem. So not wholly unique, but nice to see I’m barking up the right tree!


  1. Thank you the hacker news thread on macOCR for finding OCR software on linux.↩︎

  2. Ctl + T is used everywhere. And y is close by.↩︎