summaryrefslogtreecommitdiffstats
path: root/mkindex.pl
diff options
context:
space:
mode:
authorGuilhem Moulin <guilhem@fripost.org>2013-08-12 03:19:01 +0200
committerGuilhem Moulin <guilhem@fripost.org>2013-08-12 03:21:57 +0200
commit7602f1ecc28079adfd39488d34191ba1a442d058 (patch)
treeceec649776f4c6f3d0d035f404f4a2ab915ce5ed /mkindex.pl
parent2f5caa0110402a2cf878ce2da004950ceec572f4 (diff)
Bugfix: Geo::GDAL::TermProgress_nocb uses STDOUT but we want STDERR.
Diffstat (limited to 'mkindex.pl')
-rwxr-xr-xmkindex.pl21
1 files 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;
}