summaryrefslogtreecommitdiff
path: root/debian/ocr-scripts/xsane2ocrad.sh
blob: 0e5fb1372eae9e310649c40ef0408918f4753dfe (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
#!/bin/bash
#    xsane2ocrad - ocr with ocrad directly from xsane
#    Copyright (C) 2012 Heinrich Schwietering
# 
#    This program is free software: you can redistribute it and/or modify
#    it under the terms of the GNU General Public License as published by
#    the Free Software Foundation, either version 3 of the License, or
#    (at your option) any later version.
#
#    This program is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU General Public License for more details.
#
#    You should have received a copy of the GNU General Public License
#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
#
################################################################################
#                                                                              #
#                                  xsane2ocrad 0.1                             #
#                                                                              #
#                         ***   ocrad made simple   ***                        # 
#                                                                              # 
################################################################################
# 
# xane2ocrad is a wrapper to use Ocrad with XSane
# 
# 
#
TEMP_DIR=/tmp/      # folder for temporary files
ERRORLOG="xsane2ocrad.log"  # file where STDERR goes 

if [[ -z "$1"  ]]
  then
  echo "Usage: $0 [OPTIONS]

  xsane2ocrad scans image files with XSane, 
  recognizes the text using ocrad
  and outputs the text in a file.
  
  OPTIONS:
    -i <file1>  define input file (any image-format supported)
    -o <file2>  define output file (txt, html, hocr, rtf)
    -e <options> optional, all ocrad-Options, use quotes
 
  Progress- & error-messages will be stored in this logfile:
     $TEMP_DIR$ERRORLOG

  xsane2ocrad depends on
    - XSane, http://www.xsane.org/
    - ocrad, http://www.gnu.org/software/ocrad/
  
  Some coding was stolen from 'ocube'
  http://www.geocities.com/thierryguy/ocube.html

  This ocrad adaption is based on xsane2tess  
  http://doc.ubuntu-fr.org/xsane2tess, 

  Hints always welcome! heinrich (dot) schwietering (at) gmx (dot) de
"
  exit
fi

# get options...
while getopts ":i:o:e:" OPTION
  do
  case $OPTION in 
    i )  # input filename (with path)
      FILE_PATH="$OPTARG"
    ;;
    o )  # output filename
      FILE_OUT="$OPTARG"
    ;;
    e )  # extra options
      EXTRA="$OPTARG"
    ;;
  esac
done

# redirect STDERR to ERRORLOG
exec 2>>$TEMP_DIR$ERRORLOG
echo "~~~+++~~~~+++~~~" 1>&2

ocrad "$FILE_PATH" -o "$FILE_OUT" $EXTRA 1>&2
echo "ocrad "$FILE_PATH" -o "$FILE_OUT" $EXTRA ausgeführt" 1>&2

echo "~~~+++~~~~+++~~~"$(date +%c) 1>&2