rmagick 2.15.3 → 2.15.4
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of rmagick might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/.editorconfig +14 -0
- data/.rubocop.yml +27 -3
- data/.travis.yml +9 -6
- data/CHANGELOG.md +4 -0
- data/CONTRIBUTING.md +10 -0
- data/README.textile +4 -0
- data/before_install_linux.sh +4 -4
- data/doc/ex/gravity.rb +2 -1
- data/ext/RMagick/extconf.rb +60 -17
- data/lib/rmagick/version.rb +1 -1
- data/lib/rvg/clippath.rb +37 -36
- data/lib/rvg/container.rb +106 -107
- data/lib/rvg/deep_equal.rb +46 -48
- data/lib/rvg/describable.rb +35 -36
- data/lib/rvg/embellishable.rb +384 -380
- data/lib/rvg/misc.rb +705 -690
- data/lib/rvg/paint.rb +39 -40
- data/lib/rvg/pathdata.rb +120 -121
- data/lib/rvg/rvg.rb +212 -209
- data/lib/rvg/stretchable.rb +159 -158
- data/lib/rvg/stylable.rb +99 -100
- data/lib/rvg/text.rb +0 -1
- data/lib/rvg/transformable.rb +110 -110
- data/lib/rvg/units.rb +58 -58
- data/rmagick.gemspec +1 -1
- data/spec/rmagick/image/blue_shift_spec.rb +16 -0
- data/spec/rmagick/image/composite_spec.rb +140 -0
- data/spec/rmagick/image/constitute_spec.rb +15 -0
- data/spec/rmagick/image/dispatch_spec.rb +18 -0
- data/spec/rmagick/image/from_blob_spec.rb +14 -0
- data/spec/rmagick/image/ping_spec.rb +14 -0
- data/spec/rmagick/image/properties_spec.rb +29 -0
- data/spec/spec_helper.rb +3 -0
- data/test/Image1.rb +524 -718
- data/test/Image2.rb +1262 -1262
- data/test/Image3.rb +973 -973
- data/test/ImageList2.rb +341 -341
- data/test/Image_attributes.rb +678 -678
- data/test/Info.rb +336 -336
- data/test/Magick.rb +245 -242
- data/test/Pixel.rb +105 -105
- data/test/Preview.rb +42 -42
- metadata +21 -6
data/test/ImageList2.rb
CHANGED
@@ -7,375 +7,375 @@ require 'test/unit'
|
|
7
7
|
require 'test/unit/ui/console/testrunner' unless RUBY_VERSION[/^1\.9|^2/]
|
8
8
|
|
9
9
|
class ImageList2_UT < Test::Unit::TestCase
|
10
|
-
|
11
|
-
|
10
|
+
def setup
|
11
|
+
@ilist = Magick::ImageList.new
|
12
|
+
end
|
13
|
+
|
14
|
+
def test_append
|
15
|
+
@ilist.read(IMAGES_DIR+'/Button_0.gif', IMAGES_DIR+'/Button_0.gif')
|
16
|
+
assert_nothing_raised do
|
17
|
+
img = @ilist.append(true)
|
18
|
+
assert_instance_of(Magick::Image, img)
|
12
19
|
end
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
assert_nothing_raised do
|
17
|
-
img = @ilist.append(true)
|
18
|
-
assert_instance_of(Magick::Image, img)
|
19
|
-
end
|
20
|
-
assert_nothing_raised do
|
21
|
-
img = @ilist.append(false)
|
22
|
-
assert_instance_of(Magick::Image, img)
|
23
|
-
end
|
24
|
-
assert_raise(ArgumentError) { @ilist.append }
|
25
|
-
assert_raise(ArgumentError) { @ilist.append(true, 1) }
|
20
|
+
assert_nothing_raised do
|
21
|
+
img = @ilist.append(false)
|
22
|
+
assert_instance_of(Magick::Image, img)
|
26
23
|
end
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
24
|
+
assert_raise(ArgumentError) { @ilist.append }
|
25
|
+
assert_raise(ArgumentError) { @ilist.append(true, 1) }
|
26
|
+
end
|
27
|
+
|
28
|
+
def test_average
|
29
|
+
@ilist.read(IMAGES_DIR+'/Button_0.gif', IMAGES_DIR+'/Button_0.gif')
|
30
|
+
assert_nothing_raised do
|
31
|
+
img = @ilist.average
|
32
|
+
assert_instance_of(Magick::Image, img)
|
35
33
|
end
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
34
|
+
assert_raise(ArgumentError) { @ilist.average(1) }
|
35
|
+
end
|
36
|
+
|
37
|
+
def test_clone
|
38
|
+
@ilist.read(*Dir[IMAGES_DIR+'/Button_*.gif'])
|
39
|
+
ilist2 = @ilist.clone
|
40
|
+
assert_equal(ilist2, @ilist)
|
41
|
+
assert_equal(@ilist.frozen?, ilist2.frozen?)
|
42
|
+
assert_equal(@ilist.tainted?, ilist2.tainted?)
|
43
|
+
@ilist.taint
|
44
|
+
@ilist.freeze
|
45
|
+
ilist2 = @ilist.clone
|
46
|
+
assert_equal(@ilist.frozen?, ilist2.frozen?)
|
47
|
+
assert_equal(@ilist.tainted?, ilist2.tainted?)
|
48
|
+
end
|
49
|
+
|
50
|
+
def test_coalesce
|
51
|
+
@ilist.read(IMAGES_DIR+'/Button_0.gif', IMAGES_DIR+'/Button_0.gif')
|
52
|
+
ilist = nil
|
53
|
+
assert_nothing_raised { ilist = @ilist.coalesce }
|
54
|
+
assert_instance_of(Magick::ImageList, ilist)
|
55
|
+
assert_equal(2, ilist.length)
|
56
|
+
assert_equal(0, ilist.scene)
|
57
|
+
end
|
58
|
+
|
59
|
+
def test_copy
|
60
|
+
@ilist.read(*Dir[IMAGES_DIR+'/Button_*.gif'])
|
61
|
+
@ilist.scene = 7
|
62
|
+
ilist2 = @ilist.copy
|
63
|
+
assert_not_same(@ilist, ilist2)
|
64
|
+
assert_equal(@ilist.scene, ilist2.scene)
|
65
|
+
@ilist.each_with_index do |img, x|
|
66
|
+
assert_equal(img, ilist2[x])
|
48
67
|
end
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
68
|
+
end
|
69
|
+
|
70
|
+
def test_deconstruct
|
71
|
+
@ilist.read(IMAGES_DIR+'/Button_0.gif', IMAGES_DIR+'/Button_1.gif')
|
72
|
+
ilist = nil
|
73
|
+
assert_nothing_raised { ilist = @ilist.deconstruct }
|
74
|
+
assert_instance_of(Magick::ImageList, ilist)
|
75
|
+
assert_equal(2, ilist.length)
|
76
|
+
assert_equal(0, ilist.scene)
|
77
|
+
end
|
78
|
+
|
79
|
+
def test_dup
|
80
|
+
@ilist.read(*Dir[IMAGES_DIR+'/Button_*.gif'])
|
81
|
+
ilist2 = @ilist.dup
|
82
|
+
assert_equal(ilist2, @ilist)
|
83
|
+
assert_equal(@ilist.frozen?, ilist2.frozen?)
|
84
|
+
assert_equal(@ilist.tainted?, ilist2.tainted?)
|
85
|
+
@ilist.taint
|
86
|
+
@ilist.freeze
|
87
|
+
ilist2 = @ilist.dup
|
88
|
+
assert_not_equal(@ilist.frozen?, ilist2.frozen?)
|
89
|
+
assert_equal(@ilist.tainted?, ilist2.tainted?)
|
90
|
+
end
|
91
|
+
|
92
|
+
def flatten_images
|
93
|
+
@ilist.read(IMAGES_DIR+'/Button_0.gif', IMAGES_DIR+'/Button_1.gif')
|
94
|
+
assert_nothing_thrown do
|
95
|
+
img = @ilist.flatten_images
|
96
|
+
assert_instance_of(Magick::Image, img)
|
57
97
|
end
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
98
|
+
end
|
99
|
+
|
100
|
+
def test_from_blob
|
101
|
+
hat = File.open(FLOWER_HAT, 'rb')
|
102
|
+
blob = hat.read
|
103
|
+
assert_nothing_raised { @ilist.from_blob(blob) }
|
104
|
+
assert_instance_of(Magick::Image, @ilist[0])
|
105
|
+
assert_equal(0, @ilist.scene)
|
106
|
+
|
107
|
+
ilist2 = Magick::ImageList.new(FLOWER_HAT)
|
108
|
+
assert_equal(@ilist, ilist2)
|
109
|
+
end
|
110
|
+
|
111
|
+
def test_fx
|
112
|
+
@ilist.read(IMAGES_DIR+'/Button_0.gif', IMAGES_DIR+'/Button_1.gif')
|
113
|
+
assert_nothing_raised { @ilist.fx('1/2') }
|
114
|
+
assert_nothing_raised { @ilist.fx('1/2', Magick::BlueChannel) }
|
115
|
+
assert_nothing_raised { @ilist.fx('1/2', Magick::BlueChannel, Magick::RedChannel) }
|
116
|
+
assert_raise(ArgumentError) { @ilist.fx }
|
117
|
+
assert_raise(ArgumentError) { @ilist.fx(Magick::BlueChannel) }
|
118
|
+
assert_raise(TypeError) { @ilist.fx(1) }
|
119
|
+
assert_raise(TypeError) { @ilist.fx('1/2', 1) }
|
120
|
+
end
|
121
|
+
|
122
|
+
def test_map
|
123
|
+
map = Magick::Image.read('netscape:')[0]
|
124
|
+
@ilist.read(IMAGES_DIR+'/Button_0.gif', IMAGES_DIR+'/Button_1.gif')
|
125
|
+
assert_nothing_raised do
|
126
|
+
img = @ilist.map(map)
|
127
|
+
assert_instance_of(Magick::ImageList, img)
|
68
128
|
end
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
ilist = nil
|
73
|
-
assert_nothing_raised { ilist = @ilist.deconstruct }
|
74
|
-
assert_instance_of(Magick::ImageList, ilist)
|
75
|
-
assert_equal(2, ilist.length)
|
76
|
-
assert_equal(0, ilist.scene)
|
129
|
+
assert_nothing_raised do
|
130
|
+
img = @ilist.map(map, true)
|
131
|
+
assert_instance_of(Magick::ImageList, img)
|
77
132
|
end
|
78
133
|
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
134
|
+
map = Magick::ImageList.new('netscape:')
|
135
|
+
img = @ilist.map(map, true)
|
136
|
+
assert_instance_of(Magick::ImageList, img)
|
137
|
+
end
|
138
|
+
|
139
|
+
def test_marshal
|
140
|
+
ilist1 = Magick::ImageList.new(*Dir[IMAGES_DIR+'/Button_*.gif'])
|
141
|
+
d = nil
|
142
|
+
ilist2 = nil
|
143
|
+
assert_nothing_raised { d = Marshal.dump(ilist1) }
|
144
|
+
assert_nothing_raised { ilist2 = Marshal.load(d) }
|
145
|
+
assert_equal(ilist1, ilist2)
|
146
|
+
end
|
147
|
+
|
148
|
+
def test_montage
|
149
|
+
@ilist.read(*Dir[IMAGES_DIR+'/Button_*.gif'])
|
150
|
+
ilist = @ilist.copy
|
151
|
+
montage = nil
|
152
|
+
assert_nothing_thrown do
|
153
|
+
montage = ilist.montage do
|
154
|
+
self.background_color = 'black'
|
155
|
+
self.background_color = Magick::Pixel.new(Magick::QuantumRange, 0, 0)
|
156
|
+
self.border_color = 'red'
|
157
|
+
self.border_color = Magick::Pixel.new(0, 0, 0)
|
158
|
+
self.border_width = 2
|
159
|
+
self.compose = Magick::OverCompositeOp
|
160
|
+
self.fill = 'green'
|
161
|
+
self.font = 'Arial'
|
162
|
+
self.frame = '20x20+4+4'
|
163
|
+
self.frame = Magick::Geometry.new(20, 20, 4, 4)
|
164
|
+
self.geometry = '63x60+5+5'
|
165
|
+
self.geometry = Magick::Geometry.new(63, 60, 5, 5)
|
166
|
+
self.gravity = Magick::SouthGravity
|
167
|
+
self.matte_color = '#bdbdbd'
|
168
|
+
self.pointsize = 12
|
169
|
+
self.shadow = true
|
170
|
+
self.stroke = 'transparent'
|
171
|
+
self.tile = '4x9'
|
172
|
+
self.tile = Magick::Geometry.new(4, 9)
|
173
|
+
end
|
174
|
+
assert_instance_of(Magick::ImageList, montage)
|
175
|
+
assert_equal(@ilist, ilist)
|
90
176
|
end
|
91
177
|
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
178
|
+
# test illegal option arguments
|
179
|
+
# looks like IM doesn't diagnose invalid geometry args
|
180
|
+
# to tile= and geometry=
|
181
|
+
assert_raise(TypeError) do
|
182
|
+
montage = ilist.montage { self.background_color = 2 }
|
183
|
+
assert_equal(@ilist, ilist)
|
98
184
|
end
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
blob = hat.read
|
103
|
-
assert_nothing_raised { @ilist.from_blob(blob) }
|
104
|
-
assert_instance_of(Magick::Image, @ilist[0])
|
105
|
-
assert_equal(0, @ilist.scene)
|
106
|
-
|
107
|
-
ilist2 = Magick::ImageList.new(FLOWER_HAT)
|
108
|
-
assert_equal(@ilist, ilist2)
|
185
|
+
assert_raise(TypeError) do
|
186
|
+
montage = ilist.montage { self.border_color = 2 }
|
187
|
+
assert_equal(@ilist, ilist)
|
109
188
|
end
|
110
|
-
|
111
|
-
|
112
|
-
@ilist
|
113
|
-
assert_nothing_raised { @ilist.fx('1/2') }
|
114
|
-
assert_nothing_raised { @ilist.fx('1/2', Magick::BlueChannel) }
|
115
|
-
assert_nothing_raised { @ilist.fx('1/2', Magick::BlueChannel, Magick::RedChannel) }
|
116
|
-
assert_raise(ArgumentError) { @ilist.fx }
|
117
|
-
assert_raise(ArgumentError) { @ilist.fx(Magick::BlueChannel) }
|
118
|
-
assert_raise(TypeError) { @ilist.fx(1) }
|
119
|
-
assert_raise(TypeError) { @ilist.fx('1/2', 1) }
|
189
|
+
assert_raise(TypeError) do
|
190
|
+
montage = ilist.montage { self.border_width = [2] }
|
191
|
+
assert_equal(@ilist, ilist)
|
120
192
|
end
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
@ilist.read(IMAGES_DIR+'/Button_0.gif', IMAGES_DIR+'/Button_1.gif')
|
125
|
-
assert_nothing_raised do
|
126
|
-
img = @ilist.map(map)
|
127
|
-
assert_instance_of(Magick::ImageList, img)
|
128
|
-
end
|
129
|
-
assert_nothing_raised do
|
130
|
-
img = @ilist.map(map, true)
|
131
|
-
assert_instance_of(Magick::ImageList, img)
|
132
|
-
end
|
133
|
-
|
134
|
-
map = Magick::ImageList.new('netscape:')
|
135
|
-
img = @ilist.map(map, true)
|
136
|
-
assert_instance_of(Magick::ImageList, img)
|
193
|
+
assert_raise(TypeError) do
|
194
|
+
montage = ilist.montage { self.compose = 2 }
|
195
|
+
assert_equal(@ilist, ilist)
|
137
196
|
end
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
d = nil
|
142
|
-
ilist2 = nil
|
143
|
-
assert_nothing_raised { d = Marshal.dump(ilist1) }
|
144
|
-
assert_nothing_raised { ilist2 = Marshal.load(d) }
|
145
|
-
assert_equal(ilist1, ilist2)
|
197
|
+
assert_raise(TypeError) do
|
198
|
+
montage = ilist.montage { self.fill = 2 }
|
199
|
+
assert_equal(@ilist, ilist)
|
146
200
|
end
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
ilist = @ilist.copy
|
151
|
-
montage = nil
|
152
|
-
assert_nothing_thrown do
|
153
|
-
montage = ilist.montage do
|
154
|
-
self.background_color = 'black'
|
155
|
-
self.background_color = Magick::Pixel.new(Magick::QuantumRange, 0, 0)
|
156
|
-
self.border_color = 'red'
|
157
|
-
self.border_color = Magick::Pixel.new(0, 0, 0)
|
158
|
-
self.border_width = 2
|
159
|
-
self.compose = Magick::OverCompositeOp
|
160
|
-
self.fill = 'green'
|
161
|
-
self.font = 'Arial'
|
162
|
-
self.frame = '20x20+4+4'
|
163
|
-
self.frame = Magick::Geometry.new(20, 20, 4, 4)
|
164
|
-
self.geometry = '63x60+5+5'
|
165
|
-
self.geometry = Magick::Geometry.new(63, 60, 5, 5)
|
166
|
-
self.gravity = Magick::SouthGravity
|
167
|
-
self.matte_color = '#bdbdbd'
|
168
|
-
self.pointsize = 12
|
169
|
-
self.shadow = true
|
170
|
-
self.stroke = 'transparent'
|
171
|
-
self.tile = '4x9'
|
172
|
-
self.tile = Magick::Geometry.new(4, 9)
|
173
|
-
end
|
174
|
-
assert_instance_of(Magick::ImageList, montage)
|
175
|
-
assert_equal(@ilist, ilist)
|
176
|
-
end
|
177
|
-
|
178
|
-
# test illegal option arguments
|
179
|
-
# looks like IM doesn't diagnose invalid geometry args
|
180
|
-
# to tile= and geometry=
|
181
|
-
assert_raise(TypeError) do
|
182
|
-
montage = ilist.montage { self.background_color = 2 }
|
183
|
-
assert_equal(@ilist, ilist)
|
184
|
-
end
|
185
|
-
assert_raise(TypeError) do
|
186
|
-
montage = ilist.montage { self.border_color = 2 }
|
187
|
-
assert_equal(@ilist, ilist)
|
188
|
-
end
|
189
|
-
assert_raise(TypeError) do
|
190
|
-
montage = ilist.montage { self.border_width = [2] }
|
191
|
-
assert_equal(@ilist, ilist)
|
192
|
-
end
|
193
|
-
assert_raise(TypeError) do
|
194
|
-
montage = ilist.montage { self.compose = 2 }
|
195
|
-
assert_equal(@ilist, ilist)
|
196
|
-
end
|
197
|
-
assert_raise(TypeError) do
|
198
|
-
montage = ilist.montage { self.fill = 2 }
|
199
|
-
assert_equal(@ilist, ilist)
|
200
|
-
end
|
201
|
-
assert_raise(TypeError) do
|
202
|
-
montage = ilist.montage { self.font = 2 }
|
203
|
-
assert_equal(@ilist, ilist)
|
204
|
-
end
|
205
|
-
assert_raise(Magick::ImageMagickError) do
|
206
|
-
montage = ilist.montage { self.frame = 'z' }
|
207
|
-
assert_equal(@ilist, ilist)
|
208
|
-
end
|
209
|
-
assert_raise(TypeError) do
|
210
|
-
montage = ilist.montage { self.matte_color = 2 }
|
211
|
-
assert_equal(@ilist, ilist)
|
212
|
-
end
|
213
|
-
assert_raise(TypeError) do
|
214
|
-
montage = ilist.montage { self.pointsize = 'x' }
|
215
|
-
assert_equal(@ilist, ilist)
|
216
|
-
end
|
217
|
-
assert_raise(ArgumentError) do
|
218
|
-
montage = ilist.montage { self.stroke = 'x' }
|
219
|
-
assert_equal(@ilist, ilist)
|
220
|
-
end
|
201
|
+
assert_raise(TypeError) do
|
202
|
+
montage = ilist.montage { self.font = 2 }
|
203
|
+
assert_equal(@ilist, ilist)
|
221
204
|
end
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
assert_raise(ArgumentError) { @ilist.morph(1) }
|
226
|
-
@ilist.read(IMAGES_DIR+'/Button_0.gif', IMAGES_DIR+'/Button_1.gif')
|
227
|
-
# can't specify a negative argument
|
228
|
-
assert_raise(ArgumentError) { @ilist.morph(-1) }
|
229
|
-
assert_nothing_raised do
|
230
|
-
res = @ilist.morph(2)
|
231
|
-
assert_instance_of(Magick::ImageList, res)
|
232
|
-
assert_equal(4, res.length)
|
233
|
-
assert_equal(0, res.scene)
|
234
|
-
end
|
205
|
+
assert_raise(Magick::ImageMagickError) do
|
206
|
+
montage = ilist.montage { self.frame = 'z' }
|
207
|
+
assert_equal(@ilist, ilist)
|
235
208
|
end
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
assert_nothing_thrown do
|
240
|
-
res = @ilist.mosaic
|
241
|
-
assert_instance_of(Magick::Image, res)
|
242
|
-
end
|
209
|
+
assert_raise(TypeError) do
|
210
|
+
montage = ilist.montage { self.matte_color = 2 }
|
211
|
+
assert_equal(@ilist, ilist)
|
243
212
|
end
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
@ilist.new_image(20, 20)
|
248
|
-
end
|
249
|
-
assert_equal(1, @ilist.length)
|
250
|
-
assert_equal(0, @ilist.scene)
|
251
|
-
@ilist.new_image(20, 20, Magick::HatchFill.new('black'))
|
252
|
-
assert_equal(2, @ilist.length)
|
253
|
-
assert_equal(1, @ilist.scene)
|
254
|
-
@ilist.new_image(20, 20) { self.background_color = 'red' }
|
255
|
-
assert_equal(3, @ilist.length)
|
256
|
-
assert_equal(2, @ilist.scene)
|
213
|
+
assert_raise(TypeError) do
|
214
|
+
montage = ilist.montage { self.pointsize = 'x' }
|
215
|
+
assert_equal(@ilist, ilist)
|
257
216
|
end
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
Magick::CompareAnyLayer,
|
262
|
-
Magick::CompareClearLayer,
|
263
|
-
Magick::CompareOverlayLayer,
|
264
|
-
Magick::OptimizeLayer,
|
265
|
-
Magick::OptimizePlusLayer,
|
266
|
-
Magick::CoalesceLayer,
|
267
|
-
Magick::DisposeLayer,
|
268
|
-
Magick::OptimizeTransLayer,
|
269
|
-
Magick::RemoveDupsLayer,
|
270
|
-
Magick::RemoveZeroLayer
|
271
|
-
]
|
272
|
-
@ilist.read(IMAGES_DIR+'/Button_0.gif', IMAGES_DIR+'/Button_1.gif')
|
273
|
-
layer_methods.each do |method|
|
274
|
-
assert_nothing_raised do
|
275
|
-
res = @ilist.optimize_layers(method)
|
276
|
-
assert_instance_of(Magick::ImageList, res)
|
277
|
-
assert_equal(2, res.length)
|
278
|
-
end
|
279
|
-
end
|
280
|
-
assert_raise(ArgumentError) {@ilist.optimize_layers(Magick::UndefinedLayer)}
|
281
|
-
assert_raise(TypeError) {@ilist.optimize_layers(2)}
|
217
|
+
assert_raise(ArgumentError) do
|
218
|
+
montage = ilist.montage { self.stroke = 'x' }
|
219
|
+
assert_equal(@ilist, ilist)
|
282
220
|
end
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
221
|
+
end
|
222
|
+
|
223
|
+
def test_morph
|
224
|
+
# can't morph an empty list
|
225
|
+
assert_raise(ArgumentError) { @ilist.morph(1) }
|
226
|
+
@ilist.read(IMAGES_DIR+'/Button_0.gif', IMAGES_DIR+'/Button_1.gif')
|
227
|
+
# can't specify a negative argument
|
228
|
+
assert_raise(ArgumentError) { @ilist.morph(-1) }
|
229
|
+
assert_nothing_raised do
|
230
|
+
res = @ilist.morph(2)
|
231
|
+
assert_instance_of(Magick::ImageList, res)
|
232
|
+
assert_equal(4, res.length)
|
233
|
+
assert_equal(0, res.scene)
|
294
234
|
end
|
235
|
+
end
|
295
236
|
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
assert_equal(1, res.scene)
|
302
|
-
end
|
303
|
-
assert_nothing_raised { @ilist.quantize(128) }
|
304
|
-
assert_raise(TypeError) { @ilist.quantize('x') }
|
305
|
-
assert_nothing_raised { @ilist.quantize(128, Magick::RGBColorspace) }
|
306
|
-
assert_raise(TypeError) { @ilist.quantize(128, 'x') }
|
307
|
-
assert_nothing_raised { @ilist.quantize(128, Magick::RGBColorspace, true, 0) }
|
308
|
-
assert_nothing_raised { @ilist.quantize(128, Magick::RGBColorspace, true) }
|
309
|
-
assert_nothing_raised { @ilist.quantize(128, Magick::RGBColorspace, false) }
|
310
|
-
assert_nothing_raised { @ilist.quantize(128, Magick::RGBColorspace, Magick::NoDitherMethod) }
|
311
|
-
assert_nothing_raised { @ilist.quantize(128, Magick::RGBColorspace, Magick::RiemersmaDitherMethod) }
|
312
|
-
assert_nothing_raised { @ilist.quantize(128, Magick::RGBColorspace, Magick::FloydSteinbergDitherMethod) }
|
313
|
-
assert_raise(TypeError) { @ilist.quantize(128, Magick::RGBColorspace, true, 'x') }
|
314
|
-
assert_raise(ArgumentError) { @ilist.quantize(128, Magick::RGBColorspace, true, 0, false, 'extra') }
|
237
|
+
def test_mosaic
|
238
|
+
@ilist.read(IMAGES_DIR+'/Button_0.gif', IMAGES_DIR+'/Button_1.gif')
|
239
|
+
assert_nothing_thrown do
|
240
|
+
res = @ilist.mosaic
|
241
|
+
assert_instance_of(Magick::Image, res)
|
315
242
|
end
|
243
|
+
end
|
316
244
|
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
assert_equal(0, @ilist.scene)
|
321
|
-
assert_nothing_raised { @ilist.read(FLOWER_HAT, FLOWER_HAT) }
|
322
|
-
assert_equal(3, @ilist.length)
|
323
|
-
assert_equal(2, @ilist.scene)
|
324
|
-
assert_nothing_raised { @ilist.read(FLOWER_HAT) { self.background_color = 'red ' } }
|
325
|
-
assert_equal(4, @ilist.length)
|
326
|
-
assert_equal(3, @ilist.scene)
|
245
|
+
def test_new_image
|
246
|
+
assert_nothing_raised do
|
247
|
+
@ilist.new_image(20, 20)
|
327
248
|
end
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
|
249
|
+
assert_equal(1, @ilist.length)
|
250
|
+
assert_equal(0, @ilist.scene)
|
251
|
+
@ilist.new_image(20, 20, Magick::HatchFill.new('black'))
|
252
|
+
assert_equal(2, @ilist.length)
|
253
|
+
assert_equal(1, @ilist.scene)
|
254
|
+
@ilist.new_image(20, 20) { self.background_color = 'red' }
|
255
|
+
assert_equal(3, @ilist.length)
|
256
|
+
assert_equal(2, @ilist.scene)
|
257
|
+
end
|
258
|
+
|
259
|
+
def test_optimize_layers
|
260
|
+
layer_methods = [
|
261
|
+
Magick::CompareAnyLayer,
|
262
|
+
Magick::CompareClearLayer,
|
263
|
+
Magick::CompareOverlayLayer,
|
264
|
+
Magick::OptimizeLayer,
|
265
|
+
Magick::OptimizePlusLayer,
|
266
|
+
Magick::CoalesceLayer,
|
267
|
+
Magick::DisposeLayer,
|
268
|
+
Magick::OptimizeTransLayer,
|
269
|
+
Magick::RemoveDupsLayer,
|
270
|
+
Magick::RemoveZeroLayer
|
271
|
+
]
|
272
|
+
@ilist.read(IMAGES_DIR+'/Button_0.gif', IMAGES_DIR+'/Button_1.gif')
|
273
|
+
layer_methods.each do |method|
|
274
|
+
assert_nothing_raised do
|
275
|
+
res = @ilist.optimize_layers(method)
|
276
|
+
assert_instance_of(Magick::ImageList, res)
|
277
|
+
assert_equal(2, res.length)
|
278
|
+
end
|
342
279
|
end
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
|
280
|
+
assert_raise(ArgumentError) {@ilist.optimize_layers(Magick::UndefinedLayer)}
|
281
|
+
assert_raise(TypeError) {@ilist.optimize_layers(2)}
|
282
|
+
end
|
283
|
+
|
284
|
+
def test_ping
|
285
|
+
assert_nothing_raised { @ilist.ping(FLOWER_HAT) }
|
286
|
+
assert_equal(1, @ilist.length)
|
287
|
+
assert_equal(0, @ilist.scene)
|
288
|
+
assert_nothing_raised { @ilist.ping(FLOWER_HAT, FLOWER_HAT) }
|
289
|
+
assert_equal(3, @ilist.length)
|
290
|
+
assert_equal(2, @ilist.scene)
|
291
|
+
assert_nothing_raised { @ilist.ping(FLOWER_HAT) { self.background_color = 'red ' } }
|
292
|
+
assert_equal(4, @ilist.length)
|
293
|
+
assert_equal(3, @ilist.scene)
|
294
|
+
end
|
295
|
+
|
296
|
+
def test_quantize
|
297
|
+
@ilist.read(IMAGES_DIR+'/Button_0.gif', IMAGES_DIR+'/Button_1.gif')
|
298
|
+
assert_nothing_raised do
|
299
|
+
res = @ilist.quantize
|
300
|
+
assert_instance_of(Magick::ImageList, res)
|
301
|
+
assert_equal(1, res.scene)
|
351
302
|
end
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
|
360
|
-
|
361
|
-
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
|
366
|
-
|
367
|
-
|
368
|
-
|
369
|
-
|
370
|
-
|
371
|
-
|
372
|
-
|
373
|
-
|
374
|
-
|
375
|
-
|
376
|
-
|
377
|
-
|
303
|
+
assert_nothing_raised { @ilist.quantize(128) }
|
304
|
+
assert_raise(TypeError) { @ilist.quantize('x') }
|
305
|
+
assert_nothing_raised { @ilist.quantize(128, Magick::RGBColorspace) }
|
306
|
+
assert_raise(TypeError) { @ilist.quantize(128, 'x') }
|
307
|
+
assert_nothing_raised { @ilist.quantize(128, Magick::RGBColorspace, true, 0) }
|
308
|
+
assert_nothing_raised { @ilist.quantize(128, Magick::RGBColorspace, true) }
|
309
|
+
assert_nothing_raised { @ilist.quantize(128, Magick::RGBColorspace, false) }
|
310
|
+
assert_nothing_raised { @ilist.quantize(128, Magick::RGBColorspace, Magick::NoDitherMethod) }
|
311
|
+
assert_nothing_raised { @ilist.quantize(128, Magick::RGBColorspace, Magick::RiemersmaDitherMethod) }
|
312
|
+
assert_nothing_raised { @ilist.quantize(128, Magick::RGBColorspace, Magick::FloydSteinbergDitherMethod) }
|
313
|
+
assert_raise(TypeError) { @ilist.quantize(128, Magick::RGBColorspace, true, 'x') }
|
314
|
+
assert_raise(ArgumentError) { @ilist.quantize(128, Magick::RGBColorspace, true, 0, false, 'extra') }
|
315
|
+
end
|
316
|
+
|
317
|
+
def test_read
|
318
|
+
assert_nothing_raised { @ilist.read(FLOWER_HAT) }
|
319
|
+
assert_equal(1, @ilist.length)
|
320
|
+
assert_equal(0, @ilist.scene)
|
321
|
+
assert_nothing_raised { @ilist.read(FLOWER_HAT, FLOWER_HAT) }
|
322
|
+
assert_equal(3, @ilist.length)
|
323
|
+
assert_equal(2, @ilist.scene)
|
324
|
+
assert_nothing_raised { @ilist.read(FLOWER_HAT) { self.background_color = 'red ' } }
|
325
|
+
assert_equal(4, @ilist.length)
|
326
|
+
assert_equal(3, @ilist.scene)
|
327
|
+
end
|
328
|
+
|
329
|
+
def test_remap
|
330
|
+
@ilist.read(*Dir[IMAGES_DIR+'/Button_*.gif'])
|
331
|
+
assert_nothing_raised { @ilist.remap }
|
332
|
+
remap_image = Magick::Image.new(20,20) {self.background_color = 'green'}
|
333
|
+
assert_nothing_raised { @ilist.remap(remap_image) }
|
334
|
+
assert_nothing_raised { @ilist.remap(remap_image, Magick::NoDitherMethod) }
|
335
|
+
assert_nothing_raised { @ilist.remap(remap_image, Magick::RiemersmaDitherMethod) }
|
336
|
+
assert_nothing_raised { @ilist.remap(remap_image, Magick::FloydSteinbergDitherMethod) }
|
337
|
+
assert_raise(ArgumentError) { @ilist.remap(remap_image, Magick::NoDitherMethod, 1) }
|
338
|
+
|
339
|
+
remap_image.destroy!
|
340
|
+
assert_raise(Magick::DestroyedImageError) { @ilist.remap(remap_image) }
|
341
|
+
#assert_raise(TypeError) { @ilist.affinity(affinity_image, 1) }
|
342
|
+
end
|
343
|
+
|
344
|
+
def test_to_blob
|
345
|
+
@ilist.read(IMAGES_DIR+'/Button_0.gif')
|
346
|
+
blob = nil
|
347
|
+
assert_nothing_raised { blob = @ilist.to_blob }
|
348
|
+
img = @ilist.from_blob(blob)
|
349
|
+
assert_equal(@ilist[0], img[0])
|
350
|
+
assert_equal(1, img.scene)
|
351
|
+
end
|
352
|
+
|
353
|
+
def test_write
|
354
|
+
@ilist.read(IMAGES_DIR+'/Button_0.gif')
|
355
|
+
assert_nothing_raised do
|
356
|
+
@ilist.write('temp.gif')
|
378
357
|
end
|
358
|
+
list = Magick::ImageList.new('temp.gif')
|
359
|
+
assert_equal('GIF', list.format)
|
360
|
+
FileUtils.rm('temp.gif')
|
361
|
+
|
362
|
+
@ilist.write('jpg:temp.foo')
|
363
|
+
list = Magick::ImageList.new('temp.foo')
|
364
|
+
assert_equal('JPEG', list.format)
|
365
|
+
FileUtils.rm('temp.foo')
|
366
|
+
|
367
|
+
@ilist.write('temp.0') { self.format = 'JPEG' }
|
368
|
+
list = Magick::ImageList.new('temp.0')
|
369
|
+
assert_equal('JPEG', list.format)
|
370
|
+
FileUtils.rm('temp.0')
|
371
|
+
|
372
|
+
f = File.new('test.0', 'w')
|
373
|
+
@ilist.write(f) { self.format = 'JPEG' }
|
374
|
+
f.close
|
375
|
+
list = Magick::ImageList.new('test.0')
|
376
|
+
assert_equal('JPEG', list.format)
|
377
|
+
FileUtils.rm('test.0')
|
378
|
+
end
|
379
379
|
end
|
380
380
|
|
381
381
|
if __FILE__ == $PROGRAM_NAME
|