Created
June 5, 2016 18:19
-
-
Save StayerX/a0879aa6284521f097b4740d7c892683 to your computer and use it in GitHub Desktop.
OCR Images to text
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# Description: OCR images to text | |
# Requires: tesseract-ocr imagemagick xsel | |
# Usage: ocr-image <image(s)> | |
__ocr_image() { | |
local image | |
for image in "$@"; do | |
local tmp_img=$(mktemp) | |
cp "$image" "$tmp_img.png" | |
mogrify -modulate 100,0 -resize 700% "$tmp_img.png" | |
tesseract "$tmp_img.png" "$tmp_img" &> /dev/null | |
cp "$tmp_img.txt" "$image.txt" | |
done | |
exit 0 | |
} | |
__ocr_image "$@" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment