Git-Url: 
http://git.frugalware.org/gitweb/gitweb.cgi?p=frugalware-current.git;a=commitdiff;h=8de017f90d65280d4273c040ffe942b9b2424bd5

commit 8de017f90d65280d4273c040ffe942b9b2424bd5
Author: Slown <[email protected]>
Date:   Sun Mar 25 18:19:43 2012 +0100

xsane2tess-1.0-1-i686

* new package

diff --git a/source/apps-extra/xsane2tess/FrugalBuild 
b/source/apps-extra/xsane2tess/FrugalBuild
new file mode 100644
index 0000000..abdad01
--- /dev/null
+++ b/source/apps-extra/xsane2tess/FrugalBuild
@@ -0,0 +1,21 @@
+# Compiling Time: 0 SBU
+# Maintainer: Slown <[email protected]>
+
+pkgname=xsane2tess
+pkgver=1.0
+pkgrel=1
+pkgdesc="Script for OCR with tesseract and xsane"
+url="http://doc.ubuntu-fr.org/xsane2tess";
+depends=('tesseract-ocr' 'xsane' 'imagemagick')
+groups=('apps-extra')
+archs=('i686' 'x86_64')
+install=$pkgname.install
+up2date=$pkgver
+source=(script)
+_F_cd_path="."
+sha1sums=('c6337510f61858627228929d9ea6b872cc02734b')
+
+build() {
+       Fcd
+       Fexe script /usr/bin/$pkgname
+}
diff --git a/source/apps-extra/xsane2tess/script 
b/source/apps-extra/xsane2tess/script
new file mode 100644
index 0000000..3a3fee8
--- /dev/null
+++ b/source/apps-extra/xsane2tess/script
@@ -0,0 +1,87 @@
+#!/bin/bash
+#
+#
+##############################################################################
+#
+#                                   xsane2tess 1.0
+#
+#                          *** tesseract made simple ***
+#
+#
+##############################################################################
+#
+# xsane2tess is a TesseractOCR wrapper to be able to use tesseract with xsane
+#
+#
+#
+TEMP_DIR=/tmp/      # folder for temporary files (TIFF & tesseract data)
+ERRORLOG="xsane2tess.log"  # file where STDERR goes
+
+if [[ -z "$1"  ]]
+then
+       echo "Usage: $0 [OPTIONS]
+
+       xsane2tess converts files to TIF, scans them with TesseractOCR
+       and outputs the text in a file.
+
+       OPTIONS:
+       -i <file1>  define input file (any image-format supported)
+       -o <file2>  define output-file (*.txt)
+       -l <lang>  define language-data tesseract should use
+
+       Progress- & error-messages will be stored in this logfile:
+       $TEMP_DIR$ERRORLOG
+
+       xsane2tess depends on
+       - ImageMagick  http://www.imagemagick.org/
+       - TesseractOCR http://code.google.com/p/tesseract-ocr/
+
+       Some coding was stolen from 'ocube'
+       http://www.geocities.com/thierryguy/ocube.html
+       "
+       exit
+fi
+
+
+# get options...
+while getopts ":i:o:l:" OPTION
+do
+       case $OPTION in
+               i)  # input filename (with path)
+                       FILE_PATH="$OPTARG"
+                       ;;
+               o )  # output filename
+                       FILE_OUT="$OPTARG"
+                       ;;
+               l )  # Language-selection
+                       TES_LANG="$OPTARG"
+                       ;;
+       esac
+done
+
+# redirect STDOUT to FILE_OUT
+exec 1>>$FILE_OUT
+
+# redirect STDERR to ERRORLOG
+exec 2>>$TEMP_DIR$ERRORLOG
+
+# strip path from FILE_PATH, use filename only
+IN_FILE=${FILE_PATH##*/}
+
+TIF_FILE="$TEMP_DIR""${IN_FILE%.*}".tif
+TXT_FILE="$TEMP_DIR""${IN_FILE%.*}"
+
+# converting image into TIFF (ImageMagick)
+convert "$FILE_PATH" -compress none  "$TIF_FILE" 1>&2
+
+# start OCR (tesseract expands output with *.txt)
+tesseract "$TIF_FILE" "$TXT_FILE" -l "$TES_LANG" 1>&2
+
+# STDOUT scanned text => FILE_OUT
+cat "$TXT_FILE".txt
+
+# delete graphic file after use
+rm "$TIF_FILE"
+
+# delete tesseract output
+rm "$TXT_FILE".txt
diff --git a/source/apps-extra/xsane2tess/xsane2tess.install 
b/source/apps-extra/xsane2tess/xsane2tess.install
new file mode 100644
index 0000000..7a03e35
--- /dev/null
+++ b/source/apps-extra/xsane2tess/xsane2tess.install
@@ -0,0 +1,5 @@
+post_install() {
+
+    echo "In order to make it work, launch XSane, go to Preferences / OCR and 
enter in OCR command line : xsane2tess -l fra"
+    echo "replace fra by eng for english, deu for german, ita for italian, and 
so on. Language list  : just look at /usr/share/tessdata/"
+}
_______________________________________________
Frugalware-git mailing list
[email protected]
http://frugalware.org/mailman/listinfo/frugalware-git

Reply via email to