Skip to content

Instantly share code, notes, and snippets.

@bryceml
Created February 3, 2017 05:11
Show Gist options
  • Save bryceml/4ba62bb9f8e087d3a5f7c12200166709 to your computer and use it in GitHub Desktop.
Save bryceml/4ba62bb9f8e087d3a5f7c12200166709 to your computer and use it in GitHub Desktop.
script for selecting a part of the screen for optical character recognition and putting it on the clipboard
#!/bin/bash
# Dependencies: tesseract-ocr imagemagick scrot xsel
SCR_IMG=`mktemp`
trap "rm $SCR_IMG*" EXIT
scrot -s $SCR_IMG.png
mogrify -modulate 100,0 -resize 400% $SCR_IMG.png #should increase detection rate
tesseract $SCR_IMG.png $SCR_IMG &> /dev/null
cat $SCR_IMG.txt | xsel -bi
exit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment