Skip to content

Instantly share code, notes, and snippets.

@maxjf1
Created June 12, 2020 20:22
Show Gist options
  • Save maxjf1/b2cc85a8581b15229674c29c8ed57f97 to your computer and use it in GitHub Desktop.
Save maxjf1/b2cc85a8581b15229674c29c8ed57f97 to your computer and use it in GitHub Desktop.
OCR to clipboard script for ubuntu
#!/bin/bash
# Dependencies: tesseract-ocr
SCR_IMG=`mktemp`
trap "rm $SCR_IMG*" EXIT
gnome-screenshot -a -f $SCR_IMG.png
# increase quality with option -q from default 75 to 100
# Typo "$SCR_IMG.png000" does not continue with same name.
tesseract $SCR_IMG.png $SCR_IMG &> /dev/null
TEXT=`cat $SCR_IMG.txt | sed -e 's/^[[:space:]]*//'`
echo $TEXT
cat $SCR_IMG.txt | sed -e 's/^[[:space:]]*//' |xclip -i -selection clipboard
notify-send "OCR copiado para clipboard" "$TEXT"
rm -r $SCR_IMG.txt $SCR_IMG.png &> /dev/null
exit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment