--- scaleomat/scaleomat.pl 2004/07/23 18:19:13 1.3 +++ scaleomat/scaleomat.pl 2004/11/18 20:10:17 1.4 @@ -15,6 +15,7 @@ # Place, Suite 330, Boston, MA 02111-1307 USA use strict; +use sigtrap qw(die normal-signals); # MPIWG libraries use lib '/usr/local/mpiwg/scripts'; @@ -23,7 +24,7 @@ use MPIWGlib; $| = 1; # unblock IO -my $version = "V0.9.2 (ROC 22.4.2004)"; +my $version = "V0.9.3 (ROC 18.11.2004)"; $debug = 0; @@ -130,6 +131,22 @@ sub findfile { } +sub cleanpath { + my ($path, $startslash) = @_; + + if ($path =~ /^(\/)*(.*?)\/*$/) { + if ($startslash) { + print "$path --> $1$2\n"; + return $1 . $2; + } else { + print "$path --> $2\n"; + return $2; + } + } + print "hä? $path\n"; + return $path; +} + # # ($basename, $extension) = splitfn($filename) # @@ -156,8 +173,7 @@ sub mmkdir { # does the directory already exist? if (-d $dirname) { chmod $dir_perm, $dirname or do { - logger('ERROR', "unable to change permission on $dirname!"); - return 0; + logger('WARNING', "unable to change permission on $dirname!"); }; return 1; } @@ -189,9 +205,9 @@ sub mmkdir { # sub identify { my ($filepath) = @_; - my $pictype; - my $picwidth; - my $picheight; + my $pictype = ""; + my $picwidth = 0; + my $picheight = 0; my $bitdepth = 0; # use quickident first $pictype = quickident($filepath); @@ -202,17 +218,17 @@ sub identify { while () { chomp; if (/Image Width:\s*(\d+)\s*Image Length:\s*(\d+)/) { - $picwidth = $1; - $picheight = $2; + $picwidth = $1 if ($1 > $picwidth); + $picheight = $2 if ($2 > $picheight); next; } if (/Bits\/Sample:\s*(\d+)/) { - $bitdepth = $1; + $bitdepth = $1 if ($1 > $bitdepth); next; } } if ($picwidth) { - logger('DEBUG', "TIFF $1 x $2"); + logger('DEBUG', "TIFF $picwidth x $picheight"); return ($pictype, $picwidth, $picheight, $bitdepth); } } @@ -792,13 +808,13 @@ checksoft(); my $args = parseargs(); # source dir -my $srcdir = $$args{'src'}; +my $srcdir = cleanpath($$args{'src'}, 1); # destination dir -my $destdir = $$args{'dest'}; +my $destdir = cleanpath($$args{'dest'}, 1); # working dir -my $workdir = $$args{'dir'}; +my $workdir = cleanpath($$args{'dir'}); # destination size if ($$args{'scaleby'}) {