tileup 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- data/bin/tileup +10 -8
- data/lib/tileup.rb +10 -0
- metadata +2 -2
data/bin/tileup
CHANGED
@@ -20,13 +20,15 @@ options = {
|
|
20
20
|
}
|
21
21
|
|
22
22
|
OptionParser.new do |o|
|
23
|
-
o.on('--in=input_file', " Required input file, your large image to tile up") { |input_filename| options[:input_filename] = input_filename }
|
24
|
-
o.on('--prefix=map_tile', "Prefix to append to tile files, e.g. --prefix=my_tile => my_tile_[XN]_[YN].png") { |prefix| options[:filename_prefix] = prefix }
|
25
|
-
o.on('--tile-width=256', "Tile width, should normally equal tile height") { |width| options[:tile_width] = width }
|
26
|
-
o.on('--tile-height=256', "Tile height, should normally equal tile width") { |height| options[:tile_height] = height }
|
27
|
-
o.on('--auto-zoom=', Integer, "Automatically scale input image N times, must be a number"){ |zooms| options[:auto_zoom_levels] = zooms }
|
28
|
-
o.on('--output-dir=', "Output directory (will be created if it doesn't exist)") { |output_dir| options[:output_dir] = output_dir }
|
29
|
-
o.on('-
|
23
|
+
o.on('--in=input_file', " Required input file, your large image to tile up.") { |input_filename| options[:input_filename] = input_filename }
|
24
|
+
o.on('--prefix=map_tile', "Prefix to append to tile files, e.g. --prefix=my_tile => my_tile_[XN]_[YN].png.") { |prefix| options[:filename_prefix] = prefix }
|
25
|
+
o.on('--tile-width=256', "Tile width, should normally equal tile height.") { |width| options[:tile_width] = width }
|
26
|
+
o.on('--tile-height=256', "Tile height, should normally equal tile width.") { |height| options[:tile_height] = height }
|
27
|
+
o.on('--auto-zoom=', Integer, "Automatically scale input image N times, must be a number."){ |zooms| options[:auto_zoom_levels] = zooms }
|
28
|
+
o.on('--output-dir=', "Output directory (will be created if it doesn't exist).") { |output_dir| options[:output_dir] = output_dir }
|
29
|
+
o.on('--dont-extend-incomplete-tiles',
|
30
|
+
"Do not extend edge tiles if they do not fill an entire tile_width x tile_height. By default tileup will extend tiles to tile_width x tile_height if required.") {|e|options[:extend_incomplete_tiles] = false}
|
31
|
+
o.on('-v', '--verbose', "Enable verbose logging.") { |verbose| options[:verbose] = true }
|
30
32
|
o.on('-h', '--help', "You're looking at it.") { puts o; exit }
|
31
33
|
begin
|
32
34
|
o.parse!
|
@@ -41,4 +43,4 @@ if options[:input_filename].nil?
|
|
41
43
|
exit 1
|
42
44
|
end
|
43
45
|
|
44
|
-
TileUp::Tiler.new(options[:input_filename], options)
|
46
|
+
TileUp::Tiler.new(options[:input_filename], options)
|
data/lib/tileup.rb
CHANGED
@@ -13,6 +13,7 @@ module TileUp
|
|
13
13
|
tile_height: 256,
|
14
14
|
filename_prefix: "map_tile",
|
15
15
|
output_dir: ".",
|
16
|
+
extend_incomplete_tiles: true,
|
16
17
|
verbose: false
|
17
18
|
}
|
18
19
|
@options = OpenStruct.new(default_options.merge(options))
|
@@ -129,9 +130,18 @@ module TileUp
|
|
129
130
|
|
130
131
|
crops.each do |c|
|
131
132
|
ci = image.crop(c[:x], c[:y], tile_width, tile_height, true);
|
133
|
+
|
134
|
+
# unless told to do otherwise, extend tiles in the last row and column
|
135
|
+
# if they do not fill an entire tile width and height.
|
136
|
+
if @options.extend_incomplete_tiles && (c[:row] == num_rows - 1 || c[:column] == num_columns - 1)
|
137
|
+
# fill to width height, start from top left corner.
|
138
|
+
ci = ci.extent(tile_width, tile_height, 0, 0)
|
139
|
+
end
|
140
|
+
|
132
141
|
print "Saving tile: #{c[:row]}, #{c[:column]}..." if @options.verbose
|
133
142
|
ci.write("#{filename_prefix}_#{c[:column]}_#{c[:row]}.#{@extension}")
|
134
143
|
print "\rSaving tile: #{c[:row]}, #{c[:column]}... saved\n" if @options.verbose
|
144
|
+
|
135
145
|
ci = nil
|
136
146
|
end
|
137
147
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tileup
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-04-16 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rmagick
|