Changeset 421


Ignore:
Timestamp:
Dec 28, 2006, 10:32:50 PM (13 years ago)
Author:
Nick Burch
Message:

Do the cropping at the same time

File:
1 edited

Legend:

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

    r413 r421  
    1111my $outscale = 125;
    1212
     13# Find these values by hand using the gimp or similar
     14#  lower easting,northing
     15my @bl_trims = qw( 77, 0 );
     16#  upper easting,northing
     17my @tr_trims = qw( 657, 877 );
     18
     19# which files to build it from
    1320my @files = glob("scaled${inscale}/???/???.jpg");
    1421my %tiles ;
     
    2330}
    2431
    25 # No 000, but there is ???/000.jpg
    26 $maxx = max(keys %tiles);
     32# Ensure it starts at 0,0
     33# (Otherwise, deciding where you clicked on is too hard)
     34$maxx = max(keys %tiles) + 1;
    2735$maxy = max(map { max(keys %{$tiles{$_}})} keys %tiles) + 1;
    2836
     
    3442my $out_y = int($maxy * $tilesize * $inscale / $outscale);
    3543
     44my $trim_width = $tr_trims[0] - $bl_trims[0];
     45my $trim_height = $tr_trims[1] - $bl_trims[1];
     46
    3647print "There are $maxx images across, and $maxy images down\n";
    3748print "The temp image will be $temp_x x $temp_y\n";
    38 print "The final image will be $out_x x $out_y\n\n";
     49print "The joined image will be $out_x x $out_y\n";
     50print "The final image will be $trim_width x $trim_height\n\n";
    3951
    4052
     
    4355$out ->ReadImage('xc:white');
    4456
    45 foreach my $x (1..($maxx)) {
     57foreach my $x (0..($maxx)) {
    4658        foreach my $y (0..($maxy)) {
    4759                my $input = $tiles{$x}{$y};
     
    5163            print $image->Read($input);
    5264
    53                         # x goes from 1 to n
    54                         my $this_x = ($x-1) * $tilesize;
     65                        # x goes from 0 to n
     66                        my $this_x = $x * $tilesize;
    5567                        # y goes from 0 to n
    5668                        my $this_y = $temp_y - (($y+1) * $tilesize);
     
    6577# Now resize it
    6678$out->Resize("${out_x}x${out_y}");
     79# And trim the edges off it
     80$out->Crop( x=>$bl_trims[0], y=>($out_y - $tr_trims[1]),
     81            width=>($tr_trims[0] - $bl_trims[0]),
     82            height=>($tr_trims[1] - $bl_trims[1]) );
    6783# And make it a bit darker, so it's easier to see
    6884$out->Tint(fill=>"white", opacity=>65);
     
    7288$out->Write("jpg:thumbnail.jpg");
    7389undef $out;
     90print "\nOutput at ${trim_width}x${trim_height}\n";
    7491print "($maxx,$maxy)\n";
Note: See TracChangeset for help on using the changeset viewer.