Tesseract.pm (gscan2pdf-2.13.1.tar.xz) | : | Tesseract.pm (gscan2pdf-2.13.2.tar.xz) | ||
---|---|---|---|---|
package Gscan2pdf::Tesseract; | package Gscan2pdf::Tesseract; | |||
use 5.008005; | use 5.008005; | |||
use strict; | use strict; | |||
use warnings; | use warnings; | |||
use Carp; | use Carp; | |||
use Encode; | use Encode; | |||
use File::Temp; # To create temporary files | use File::Temp; # To create temporary files | |||
use File::Basename; | use File::Basename; | |||
use Gscan2pdf::Document; # for slurp | use Gscan2pdf::Document; # for slurp | |||
use version; | use version; | |||
use English qw( -no_match_vars ); # for $PROCESS_ID | use English qw( -no_match_vars ); # for $PROCESS_ID | |||
use Gscan2pdf::Translation '__'; # easier to extract strings with xgettext | use Gscan2pdf::Translation '__'; # easier to extract strings with xgettext | |||
use Locale::Language; | use Locale::Language; | |||
use Readonly; | use Readonly; | |||
Readonly our $DPI_OPTION_POS => 3; | Readonly our $DPI_OPTION_POS => 3; | |||
our $VERSION = '2.13.1'; | our $VERSION = '2.13.2'; | |||
my $EMPTY = q{}; | my $EMPTY = q{}; | |||
my $COMMA = q{,}; | my $COMMA = q{,}; | |||
my ( %languages, %installable_languages, $installed, $setup, $version, | my ( %languages, %installable_languages, $installed, $setup, $version, | |||
$logger ); | $logger ); | |||
# Taken from | # Taken from | |||
# https://github.com/tesseract-ocr/tesseract/blob/master/doc/tesseract.1.asc#lan guages | # https://github.com/tesseract-ocr/tesseract/blob/master/doc/tesseract.1.asc#lan guages | |||
my @installable_languages = | my @installable_languages = | |||
qw(afr amh ara asm aze aze-cyrl bel ben bod bos bre bul cat ceb ces chi-sim | qw(afr amh ara asm aze aze-cyrl bel ben bod bos bre bul cat ceb ces chi-sim | |||
skipping to change at line 200 | skipping to change at line 200 | |||
if ( defined $options{threshold} and $options{threshold} ) { | if ( defined $options{threshold} and $options{threshold} ) { | |||
# Temporary filename for new file | # Temporary filename for new file | |||
$tif = File::Temp->new( SUFFIX => '.tif' ); | $tif = File::Temp->new( SUFFIX => '.tif' ); | |||
my @cmd; | my @cmd; | |||
if ( defined $options{threshold} and $options{threshold} ) { | if ( defined $options{threshold} and $options{threshold} ) { | |||
$logger->info("thresholding at $options{threshold} to $tif"); | $logger->info("thresholding at $options{threshold} to $tif"); | |||
@cmd = ( | @cmd = ( | |||
'convert', $options{file}, '+dither', '-threshold', | 'convert', $options{file}, '+dither', '-threshold', | |||
"$options{threshold}%", '-depth', 1, $tif, | "$options{threshold}%", '-depth', 1, $tif, | |||
); | ); | |||
} | } | |||
else { | else { | |||
$logger->info("writing temporary image $tif"); | $logger->info("writing temporary image $tif"); | |||
@cmd = ( 'convert', $options{file}, $tif ); | @cmd = ( 'convert', $options{file}, $tif ); | |||
} | } | |||
my ( $status, $stdout, $stderr ) = | my ( $status, $stdout, $stderr ) = | |||
Gscan2pdf::Document::exec_command( \@cmd ); | Gscan2pdf::Document::exec_command( \@cmd ); | |||
if ( $status != 0 ) { | if ( $status != 0 ) { | |||
return $stdout, $stderr; | return $stdout, $stderr; | |||
End of changes. 4 change blocks. | ||||
5 lines changed or deleted | 5 lines changed or added |