Commit: e6b95e79edf0fa483f92fe824ca94f4625772e2a Parent: 773966e94c347dcbb886e901125c37c31b29434f Author: Randy Palamar Date: Sun, 4 Jul 2021 20:10:24 -0600 cleanup imageocr script and rename to ocr Diffstat:
D | bin/imageocr | | | 11 | ----------- |
A | bin/ocr | | | 30 | ++++++++++++++++++++++++++++++ |
2 files changed, 30 insertions(+), 11 deletions(-)
diff --git a/bin/imageocr b/bin/imageocr @@ -1,11 +0,0 @@ -#!/bin/sh - -# copy japanese text from an image to the clipboard -# deps: imagemagick tesseract slop xclip -# you probably want the capture2text jpn file from here: -# https://sourceforge.net/projects/capture2text/files/Dictionaries/Japanese.zip/download - -import -window root -crop $(slop -f '%g') png:- |\ -tesseract stdin stdout -l jpn --tessdata-dir ~/.local/share/tesseract |\ -tr -d ' ' |\ -xclip -sel clip diff --git a/bin/ocr b/bin/ocr @@ -0,0 +1,30 @@ +#!/bin/sh + +# copy text from an image to the clipboard +# deps: imagemagick tesseract slop xclip +# you probably want the capture2text jpn file from here: +# https://sourceforge.net/projects/capture2text/files/Dictionaries/Japanese.zip/download + +TESS_DATA="$HOME/.local/share/tesseract" + +usage() { + echo "usage: ocr [-l lang][-d dpi]" + exit 1 +} + +while getopts "ld:" arg; do + case "${arg}" in + d) dpi="${OPTARG}" ;; + l) lang="${OPTARG}" ;; + *) usage ;; + esac +done + +lang=${lang:-jpn} +dpi=${dpi:-96} + +import -window root -crop $(slop -f '%g') png:- | +tesseract stdin stdout \ + --dpi $dpi -l $lang \ + --tessdata-dir "$TESS_DATA" | +xclip -sel clip