From 7602f1ecc28079adfd39488d34191ba1a442d058 Mon Sep 17 00:00:00 2001 From: Guilhem Moulin Date: Mon, 12 Aug 2013 03:19:01 +0200 Subject: Bugfix: Geo::GDAL::TermProgress_nocb uses STDOUT but we want STDERR. --- mkindex.pl | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/mkindex.pl b/mkindex.pl index 9573394..0e49878 100755 --- a/mkindex.pl +++ b/mkindex.pl @@ -183,9 +183,13 @@ use Geo::OSR; # http://www.imagemagick.org/script/perl-magick.php use Image::Magick; -my %config = ( progress => Geo::GDAL->can('TermProgress_nocb') ? - sub { Geo::GDAL::TermProgress_nocb(@_[0,1]) } : - *Geo::GDAL::TermProgress +my %config = ( progress => sub { + open *X, '>&', \*STDOUT or die "Can't dup STDOUT: $!"; + open STDOUT, '>&', STDERR or die "Can't dup STDERR: $!"; + Geo::GDAL::TermProgress_nocb(@_[0,1]); + open STDOUT, '>&', \*X or die "Can't dup X: $!"; + close *X; + } , debug => 0 , rename => 's/\.[^.]+$//' , outsize => [ 1024, 0 ] @@ -414,8 +418,14 @@ sub merge { (keys %$driver_opts); my @src_filenames = map {$_->{filename}} @mapset; - system 'gdalwarp', @opts, @src_filenames, $dst_filename; - $? == 0 or die "gdalwarp failed.\n"; + { + open *X, '>&', \*STDOUT or die "Can't dup STDOUT: $!"; + open STDOUT, '>&', STDERR or die "Can't dup STDERR: $!"; + system 'gdalwarp', @opts, @src_filenames, $dst_filename; + $? == 0 or die "gdalwarp failed.\n"; + open STDOUT, '>&', \*X or die "Can't dup X: $!"; + close *X; + } return $dst_filename; } @@ -477,6 +487,7 @@ sub annotate { $img->Composite( image => $text, compose => 'Over' ); undef $text; } + binmode STDOUT if $index =~ /^(?:[[:alnum:]]*:)?-$/; # Useful for pipes $img->Write($index); undef $img; } -- cgit v1.2.3