imagetiler 0.1.5 → 0.1.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +4 -0
- data/README.markdown +2 -2
- data/VERSION +1 -1
- data/imagetiler.gemspec +4 -3
- data/lib/imagetiler.rb +9 -17
- metadata +5 -4
data/.gitignore
ADDED
data/README.markdown
CHANGED
@@ -23,6 +23,7 @@ Install the gem:
|
|
23
23
|
`gem install imagetiler`
|
24
24
|
|
25
25
|
Use it in your code:
|
26
|
+
require 'rubygems' # if you installed imagetiler as a gem
|
26
27
|
require 'imagetiler'
|
27
28
|
t = Tiler.new
|
28
29
|
t.make_tiles(image_source, opts)
|
@@ -43,7 +44,7 @@ If you set an option in get_tiles, that will be the new default for that instanc
|
|
43
44
|
`output_dir` : Defaults to the current directory. Don't include the ending '/'
|
44
45
|
`bg_color` : The background fill color, transparent by default.
|
45
46
|
`autocreate_dirs` : Whether or not to create the directory if it exists. Default true
|
46
|
-
`format` : The format for the output, defaults to '
|
47
|
+
`format` : The format for the output, defaults to 'png'. Can be png, jpg, gif, or anything that ImageMagick supports.
|
47
48
|
`prefix` : Prefix for the output files. Defaults to 'tile'
|
48
49
|
|
49
50
|
|
@@ -61,7 +62,6 @@ Tiles in the output folder with format
|
|
61
62
|
|
62
63
|
## Other things
|
63
64
|
* Requires rmagick and ImageMagick.
|
64
|
-
* Might not work on Windows as written -- change the '/' for the output to '\\'
|
65
65
|
|
66
66
|
|
67
67
|
## Credits
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.6
|
data/imagetiler.gemspec
CHANGED
@@ -5,18 +5,19 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{imagetiler}
|
8
|
-
s.version = "0.1.
|
8
|
+
s.version = "0.1.6"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Anna, Guilhem Vellut"]
|
12
|
-
s.date = %q{2010-
|
12
|
+
s.date = %q{2010-10-14}
|
13
13
|
s.description = %q{imagetiler is a simple command-line and ruby image tiler with support for multiple zoom levels and different image formats.}
|
14
14
|
s.email = %q{tanna22@gmail.com}
|
15
15
|
s.extra_rdoc_files = [
|
16
16
|
"README.markdown"
|
17
17
|
]
|
18
18
|
s.files = [
|
19
|
-
"
|
19
|
+
".gitignore",
|
20
|
+
"README.markdown",
|
20
21
|
"Rakefile",
|
21
22
|
"VERSION",
|
22
23
|
"imagetiler.gemspec",
|
data/lib/imagetiler.rb
CHANGED
@@ -31,7 +31,7 @@ class Tiler
|
|
31
31
|
def initialize()
|
32
32
|
@zoom_levels = 0..4
|
33
33
|
@bg_color = Magick::Pixel.new(255,255,255,Magick::TransparentOpacity)
|
34
|
-
@format = "
|
34
|
+
@format = "png"
|
35
35
|
@autocreate_dirs = true
|
36
36
|
@output_dir = "."
|
37
37
|
@prefix = "tile"
|
@@ -42,14 +42,9 @@ class Tiler
|
|
42
42
|
|
43
43
|
# initializing and setting options and stuff
|
44
44
|
image = get_image(image_source)
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
if opts[:bg_color] then @bg_color = opts[:bg_color] end
|
49
|
-
if opts[:format] then @format = opts[:format] end
|
50
|
-
if opts[:autocreate_dirs] then @autocreate_dirs = opts[:autocreate_dirs] end
|
51
|
-
if opts[:output_dir] then @output_dir = opts[:output_dir] end
|
52
|
-
@prefix = opts[:prefix] if opts[:prefix]
|
45
|
+
opts.each_pair do |key,value|
|
46
|
+
instance_variable_set "@#{key}", value
|
47
|
+
end
|
53
48
|
|
54
49
|
if @autocreate_dirs
|
55
50
|
create_dir(output_dir)
|
@@ -77,7 +72,8 @@ class Tiler
|
|
77
72
|
tile.resize!(TILE_SIZE,TILE_SIZE)
|
78
73
|
|
79
74
|
# output tile
|
80
|
-
|
75
|
+
filename = File.join(@output_dir, "#{prefix}_#{zoom}_#{col}_#{row}.#{@format}")
|
76
|
+
tile.write(filename)
|
81
77
|
end
|
82
78
|
end
|
83
79
|
end
|
@@ -98,14 +94,10 @@ class Tiler
|
|
98
94
|
# image is square and that the max number of pixels
|
99
95
|
# is evenly divisible by the max number of tiles per side
|
100
96
|
def pad_image(image)
|
101
|
-
|
97
|
+
dim = calc_side_length(image)
|
102
98
|
|
103
|
-
|
104
|
-
|
105
|
-
self.background_color = bg_color
|
106
|
-
end
|
107
|
-
|
108
|
-
image_sq.import_pixels(0,0,image.columns,image.rows,"RGBA",image.export_pixels(0,0,image.columns,image.rows,"RGBA"))
|
99
|
+
image.background_color = @bg_color
|
100
|
+
image.extent(dim, dim)
|
109
101
|
end
|
110
102
|
|
111
103
|
def get_image(image_source)
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: imagetiler
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 23
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 0.1.
|
9
|
+
- 6
|
10
|
+
version: 0.1.6
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Anna, Guilhem Vellut
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2010-
|
18
|
+
date: 2010-10-14 00:00:00 -04:00
|
19
19
|
default_executable:
|
20
20
|
dependencies: []
|
21
21
|
|
@@ -28,6 +28,7 @@ extensions: []
|
|
28
28
|
extra_rdoc_files:
|
29
29
|
- README.markdown
|
30
30
|
files:
|
31
|
+
- .gitignore
|
31
32
|
- README.markdown
|
32
33
|
- Rakefile
|
33
34
|
- VERSION
|