--- stich.pl 2007/10/15 21:15:26 2 +++ stich.pl 2007/10/16 09:27:16 10 @@ -9,6 +9,14 @@ use File::Find; use Data::Dump qw/dump/; use Imager; +use Getopt::Long; + +# Mireo 1, Google 0 +my $flip_vertical = 0; + +GetOptions( + 'flip-vertical' => \$flip_vertical, +); my $path = shift @ARGV || die "usage: $0 path_to_dump_dir\n"; @@ -95,14 +103,19 @@ print "final map size: $x_size x $y_size from $x_tiles x $y_tiles tiles\n"; -my $map = Imager->new( xsize => $x_size, ysize => $y_size ); +my $map = Imager->new( xsize => $x_size, ysize => $y_size ) or $img->errstr(); foreach my $tile_file ( @files ) { $img->read( file => "$path/$tile_file" ) or die $img->errstr(); # this is specific to globe position, I guess ... this is europe my $x = ( $file_pos->{$tile_file}->{x} - $range->{min}->{x} ) / $step->{x}; - my $y = ( $range->{max}->{y} - $file_pos->{$tile_file}->{y} ) / $step->{y}; + my $y; + if ( $flip_vertical ) { + $y = ( $range->{max}->{y} - $file_pos->{$tile_file}->{y} ) / $step->{y}; + } else { + $y = ( $file_pos->{$tile_file}->{y} - $range->{min}->{y} ) / $step->{y}; + } printf("%3dx%-3d %s\n", $x, $y, $tile_file); @@ -113,4 +126,8 @@ ); } -$map->write( file => 'dump.png' ) or die $img->errstr(); +$path =~ s/\W+/_/g; +$path =~ s/^_+//; +$path =~ s/_+$//; + +$map->write( file => "$path.png" ) or die $img->errstr();