diff --git a/translate.sh b/translate.sh new file mode 100755 index 0000000..19f6f06 --- /dev/null +++ b/translate.sh @@ -0,0 +1,16 @@ +#!/bin/bash + +REGION=$(slurp -f "%x %y %w %h") +[ -z "$REGION" ] && exit 0 +TMP=$(mktemp /tmp/ocr-XXXX.png) +flameshot screen --raw > "$TMP" +python3 - "$REGION" "$TMP" << 'EOF' +import sys +from PIL import Image +x, y, w, h = map(int, sys.argv[1].split()) +tmp = sys.argv[2] +img = Image.open(tmp) +img.crop((x, y, x+w, y+h)).save(tmp) +EOF +cat $TMP | wl-copy +rm "$TMP"