Submitted by: on (See http://fuzzyocr.own-hero.net/ticket/421) Date: 2007-11-15 Initial Package Version: 3.5.1 Upstream Status: Accepted but no time to work on project any more Description: From on: I knew for sure something was not right in the way the function get_tmpdir was running. After adding some tracing information, it shows that the function always return the same value, instead of returning a value depending on the image being analyzed. So this patch generates the temporary directory with File::Basename::dirname of the input file whenever it is needed. The temporary file for analysis becomes the temporary directory where the original image is saved. This seems to apply for the error in ticket #110 about pamthreshold error and ticket #419 about gifsicle error. diff -ur FuzzyOcr.orig/Deanimate.pm FuzzyOcr/Deanimate.pm --- FuzzyOcr.orig/Deanimate.pm Sun Jan 7 19:05:18 2007 +++ FuzzyOcr/Deanimate.pm Thu Nov 15 13:19:00 2007 @@ -8,13 +8,14 @@ use FuzzyOcr::Config qw(get_config set_config get_tmpdir); use FuzzyOcr::Misc qw(save_execute); use FuzzyOcr::Logging qw(errorlog warnlog infolog); +use File::Basename qw(dirname); # Provide functions to deanimate gifs sub deanimate { my $conf = get_config(); - my $imgdir = get_tmpdir(); my $tfile = shift; + my $imgdir = dirname($tfile); my $efile = $tfile . ".err"; my $tfile2 = $tfile; my $tfile3 = $tfile; @@ -58,8 +59,8 @@ sub gif_info { my $conf = get_config(); - my $imgdir = get_tmpdir(); my $giffile = $_[0]; + my $imgdir = dirname($giffile); my $fd = new IO::Handle; diff -ur FuzzyOcr.orig/Preprocessor.pm FuzzyOcr/Preprocessor.pm --- FuzzyOcr.orig/Preprocessor.pm Sun Jan 7 19:05:18 2007 +++ FuzzyOcr/Preprocessor.pm Thu Nov 15 12:31:05 2007 @@ -1,5 +1,7 @@ package FuzzyOcr::Preprocessor; +use File::Basename qw(dirname); + sub new { my ($class, $label, $command, $args) = @_; @@ -12,7 +14,7 @@ sub run { my ($self, $input) = @_; - my $tmpdir = FuzzyOcr::Config::get_tmpdir(); + my $tmpdir = dirname($input); my $label = $self->{label}; my $output = "$tmpdir/prep.$label.out"; my $stderr = ">$tmpdir/prep.$label.err"; diff -ur FuzzyOcr.orig/Scanset.pm FuzzyOcr/Scanset.pm --- FuzzyOcr.orig/Scanset.pm Sun Jan 7 19:05:18 2007 +++ FuzzyOcr/Scanset.pm Thu Nov 15 13:20:39 2007 @@ -2,6 +2,7 @@ use lib qw(..); use FuzzyOcr::Logging qw(errorlog); +use File::Basename qw(dirname); sub new { my ($class, $label, $preprocessors, $command, $args, $output_in) = @_; @@ -19,7 +20,7 @@ sub run { my ($self, $input) = @_; my $conf = FuzzyOcr::Config::get_config(); - my $tmpdir = FuzzyOcr::Config::get_tmpdir(); + my $tmpdir = dirname($input); my $label = $self->{label}; my $output = "$tmpdir/scanset.$label.out"; my $stderr = ">$tmpdir/scanset.$label.err";