Changeset 421
- Timestamp:
- Dec 28, 2006, 10:32:50 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/npemap.org.uk/scripts/tile-processing/makeThumbImage.pl
r413 r421 11 11 my $outscale = 125; 12 12 13 # Find these values by hand using the gimp or similar 14 # lower easting,northing 15 my @bl_trims = qw( 77, 0 ); 16 # upper easting,northing 17 my @tr_trims = qw( 657, 877 ); 18 19 # which files to build it from 13 20 my @files = glob("scaled${inscale}/???/???.jpg"); 14 21 my %tiles ; … … 23 30 } 24 31 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; 27 35 $maxy = max(map { max(keys %{$tiles{$_}})} keys %tiles) + 1; 28 36 … … 34 42 my $out_y = int($maxy * $tilesize * $inscale / $outscale); 35 43 44 my $trim_width = $tr_trims[0] - $bl_trims[0]; 45 my $trim_height = $tr_trims[1] - $bl_trims[1]; 46 36 47 print "There are $maxx images across, and $maxy images down\n"; 37 48 print "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"; 49 print "The joined image will be $out_x x $out_y\n"; 50 print "The final image will be $trim_width x $trim_height\n\n"; 39 51 40 52 … … 43 55 $out ->ReadImage('xc:white'); 44 56 45 foreach my $x ( 1..($maxx)) {57 foreach my $x (0..($maxx)) { 46 58 foreach my $y (0..($maxy)) { 47 59 my $input = $tiles{$x}{$y}; … … 51 63 print $image->Read($input); 52 64 53 # x goes from 1to n54 my $this_x = ($x-1)* $tilesize;65 # x goes from 0 to n 66 my $this_x = $x * $tilesize; 55 67 # y goes from 0 to n 56 68 my $this_y = $temp_y - (($y+1) * $tilesize); … … 65 77 # Now resize it 66 78 $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]) ); 67 83 # And make it a bit darker, so it's easier to see 68 84 $out->Tint(fill=>"white", opacity=>65); … … 72 88 $out->Write("jpg:thumbnail.jpg"); 73 89 undef $out; 90 print "\nOutput at ${trim_width}x${trim_height}\n"; 74 91 print "($maxx,$maxy)\n";
Note: See TracChangeset
for help on using the changeset viewer.