Skip to content

Instantly share code, notes, and snippets.

@Dimfred
Created May 10, 2022 15:03
Show Gist options
  • Save Dimfred/189e0e695bf4f96dcd761147ca92113b to your computer and use it in GitHub Desktop.
Save Dimfred/189e0e695bf4f96dcd761147ca92113b to your computer and use it in GitHub Desktop.
Text from screenshot with tesseract
#!/usr/bin/env sh
main() {
# path to store tmp stuff
dir=/tmp
# tmp path of the img to process by tesseract
out_img=$dir/tesseract_img.png
# output text read from the img
out_txt=$dir/tesseract_text
# make a screenshot from selection
maim -s $out_img
# detect
tesseract $out_img $out_txt
# read the text
cat $out_txt.txt | xclip -selection clipboard
}
main $@
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment