Changeset 411


Ignore:
Timestamp:
Dec 9, 2006, 6:01:47 PM (13 years ago)
Author:
Nick Burch
Message:

Support some on-the-fly resizing when building really big scaled files

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/npemap.org.uk/scripts/tile-processing/makeSmaller.pl

    r409 r411  
    88my $scale = shift;
    99unless($scale) { $scale = 6; }
     10
     11# Should we rescale as we go?
     12my $rescale_by = 1;
     13if($scale > 20) {
     14        $rescale_by = 4;
     15}
     16my $out_tile_size = int($tilesize / $rescale_by);
    1017
    1118my $outdir = "scaled$scale";
     
    4249        if( (! -f $filename) && any_tiles($x, $y, \%tiles) ) {
    4350            print "Making $filename\n";
    44             my $out = Image::Magick->new(size => ($tilesize * $scale). "x".($tilesize *$scale));
     51            my $out = Image::Magick->new( size => "".($out_tile_size*$scale)."x".($out_tile_size*$scale) );
    4552            $out ->ReadImage('xc:white');
    4653
     
    5259     foreach my $j (0..($scale -1)) {
    5360         if (defined $tiles{($x*$scale)+$i}{($y*$scale)+$j}) {
     61            my $input = $tiles{($x*$scale)+$i}{($y*$scale)+$j};
    5462            my $image = Image::Magick->new;
    55             my $input = $tiles{($x*$scale)+$i}{($y*$scale)+$j};
     63            print $image->Read($input);
    5664                        #print "  Including $input\n";
    5765
    58             print $image->Read($input);
    59             print $out->Composite(image=>$image, x=>($i*$tilesize), y=>((($scale -1)-$j)*$tilesize));
     66                        if($rescale_by > 1) {
     67                                $image->Resize("${out_tile_size}x${out_tile_size}");
     68                                #print "Resized $input to ${out_tile_size}x${out_tile_size}\n";
     69                        }
     70
     71            print $out->Composite(image=>$image, x=> ($i*$out_tile_size), y=> ((($scale -1)-$j)*$out_tile_size) );
    6072            undef $image;
    6173        }
Note: See TracChangeset for help on using the changeset viewer.