#! /usr/bin/perl -w

use strict;
use Getopt::Long;

my $logfile = "/tmp/tesseract.log";
my $lang;
my $inputfile;
my $outputfile;

GetOptions ('log=s' => \$logfile,
	    'l=s' => \$lang,
	    'i=s' => \$inputfile,
	    'o=s' => \$outputfile
    );

open (LOG,"> $logfile") or die "Error Opening log file $logfile\n";

print LOG "Xsane to Tesseract by EquinoxeFR\n";
print LOG "-i $inputfile\n";
print LOG "-o $outputfile\n";
print LOG "-l $lang\n";

print LOG `convert "$inputfile" -compress none "${outputfile}.tif"`;
print LOG `tesseract "${outputfile}.tif" "${outputfile}" -l $lang`;

unlink( "${outputfile}.tif");
unlink( "${outputfile}");

close(LOG);
