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
@@ -0,0 +1,15 @@
|
|
1
|
+
RSpec.describe Magick::Image, '#constitute' do
|
2
|
+
|
3
|
+
let(:img) { Magick::Image.read(IMAGES_DIR+'/Button_0.gif').first }
|
4
|
+
let(:pixels) { img.dispatch(0, 0, img.columns, img.rows, 'RGBA') }
|
5
|
+
|
6
|
+
it 'returns an equivalent image to the given pixels' do
|
7
|
+
res = Magick::Image.constitute(img.columns, img.rows, 'RGBA', pixels)
|
8
|
+
# The constituted image is in MIFF format so we
|
9
|
+
# can't compare it directly to the original image.
|
10
|
+
expect(res.columns).to eq img.columns
|
11
|
+
expect(res.rows).to eq img.rows
|
12
|
+
expect(pixels.all? { |v| 0 <= v && v <= Magick::QuantumRange }).to be true
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
RSpec.describe Magick::Image, '#dispatch' do
|
2
|
+
|
3
|
+
let(:img) { Magick::Image.read(IMAGES_DIR+'/Button_0.gif').first }
|
4
|
+
|
5
|
+
it 'expects exactly 5 or 6 arguments' do
|
6
|
+
expect { img.dispatch }.to raise_error(ArgumentError)
|
7
|
+
expect { img.dispatch(0) }.to raise_error(ArgumentError)
|
8
|
+
expect { img.dispatch(0, 0) }.to raise_error(ArgumentError)
|
9
|
+
expect { img.dispatch(0, 0, img.columns) }.to raise_error(ArgumentError)
|
10
|
+
expect do
|
11
|
+
img.dispatch(0, 0, img.columns, img.rows)
|
12
|
+
end.to raise_error(ArgumentError)
|
13
|
+
expect do
|
14
|
+
img.dispatch(0, 0, 20, 20, 'RGBA', false, false)
|
15
|
+
end.to raise_error(ArgumentError)
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
RSpec.describe Magick::Image, '#from_blob' do
|
2
|
+
|
3
|
+
let(:img) { Magick::Image.read(IMAGES_DIR+'/Button_0.gif').first }
|
4
|
+
let(:blob) { img.to_blob }
|
5
|
+
|
6
|
+
it 'returns an image equal to the original' do
|
7
|
+
expect(blob).to be_instance_of(String)
|
8
|
+
res = Magick::Image.from_blob(blob)
|
9
|
+
expect(res).to be_instance_of(Array)
|
10
|
+
expect(res.first).to be_instance_of(Magick::Image)
|
11
|
+
expect(res.first).to eq img
|
12
|
+
end
|
13
|
+
|
14
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
RSpec.describe Magick::Image, '#ping' do
|
2
|
+
|
3
|
+
it 'returns an image from the source, omitting pixel data' do
|
4
|
+
res = Magick::Image.ping(IMAGES_DIR+'/Button_0.gif')
|
5
|
+
expect(res).to be_instance_of(Array)
|
6
|
+
image = res.first
|
7
|
+
expect(image).to be_instance_of(Magick::Image)
|
8
|
+
expect(image.format).to eq 'GIF'
|
9
|
+
expect(image.columns).to eq 127
|
10
|
+
expect(image.rows).to eq 120
|
11
|
+
expect(image.filename).to match(/Button_0.gif/)
|
12
|
+
end
|
13
|
+
|
14
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
RSpec.describe Magick::Image, '#properties' do
|
2
|
+
|
3
|
+
let(:img) { Magick::Image.new(20, 20) }
|
4
|
+
let(:freeze_error) { RUBY_VERSION[/^1\.9|^2/] ? RuntimeError : TypeError }
|
5
|
+
|
6
|
+
before(:each) do
|
7
|
+
img['a'] = 'str_1'
|
8
|
+
img['b'] = 'str_2'
|
9
|
+
img['c'] = 'str_3'
|
10
|
+
end
|
11
|
+
|
12
|
+
it 'allows assignment of arbitrary properties' do
|
13
|
+
expect(img['a']).to eq 'str_1'
|
14
|
+
expect(img['b']).to eq 'str_2'
|
15
|
+
expect(img['c']).to eq 'str_3'
|
16
|
+
expect(img['d']).to be nil
|
17
|
+
end
|
18
|
+
|
19
|
+
it 'returns a hash of assigned properties' do
|
20
|
+
expected_properties = { 'a' => 'str_1', 'b' => 'str_2', 'c' => 'str_3' }
|
21
|
+
expect(img.properties).to eq(expected_properties)
|
22
|
+
end
|
23
|
+
|
24
|
+
it 'raises an error when trying to assign properties to a frozen image' do
|
25
|
+
img.freeze
|
26
|
+
expect { img['d'] = 'str_4' }.to raise_error(freeze_error)
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
data/spec/spec_helper.rb
CHANGED
data/test/Image1.rb
CHANGED
@@ -5,751 +5,557 @@ require 'test/unit'
|
|
5
5
|
require 'test/unit/ui/console/testrunner' unless RUBY_VERSION[/^1\.9|^2/]
|
6
6
|
|
7
7
|
class Image1_UT < Test::Unit::TestCase
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
@img['d'] = 'string4'
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
def test_blue_shift
|
46
|
-
img = Magick::Image.read(IMAGES_DIR+'/Button_0.gif')[0]
|
47
|
-
res = nil
|
48
|
-
assert_nothing_raised { res = img.blue_shift }
|
49
|
-
assert_instance_of(Magick::Image, res)
|
50
|
-
assert_not_same(img, res)
|
51
|
-
assert_nothing_raised { img.blue_shift(2) }
|
52
|
-
assert_raise(ArgumentError) { img.blue_shift(2, 3) }
|
53
|
-
end
|
54
|
-
|
55
|
-
# test constitute and dispatch
|
56
|
-
def test_constitute
|
57
|
-
@img = Magick::Image.read(IMAGES_DIR+'/Button_0.gif')[0]
|
58
|
-
assert_nothing_raised do
|
59
|
-
pixels = @img.dispatch(0, 0, @img.columns, @img.rows, 'RGBA')
|
60
|
-
res = Magick::Image.constitute(@img.columns, @img.rows, 'RGBA', pixels)
|
61
|
-
# The constituted image is in MIFF format so we
|
62
|
-
# can't compare it directly to the original image.
|
63
|
-
assert_equal(@img.columns, res.columns)
|
64
|
-
assert_equal(@img.rows, res.rows)
|
65
|
-
assert_block { pixels.all? { |v| 0 <= v && v <= Magick::QuantumRange } }
|
66
|
-
end
|
67
|
-
|
68
|
-
pixels = @img.dispatch(0, 0, @img.columns, @img.rows, 'RGBA', true)
|
69
|
-
assert_block { pixels.all? { |v| 0.0 <= v && v <= 1.0 } }
|
70
|
-
|
71
|
-
# dispatch wants exactly 5 or exactly 6 arguments
|
72
|
-
assert_raise(ArgumentError) { @img.dispatch }
|
73
|
-
assert_raise(ArgumentError) { @img.dispatch(0) }
|
74
|
-
assert_raise(ArgumentError) { @img.dispatch(0, 0) }
|
75
|
-
assert_raise(ArgumentError) { @img.dispatch(0, 0, @img.columns) }
|
76
|
-
assert_raise(ArgumentError) { @img.dispatch(0, 0, @img.columns, @img.rows) }
|
77
|
-
assert_raise(ArgumentError) { @img.dispatch(0, 0, 20, 20, 'RGBA', false, false) }
|
78
|
-
end
|
79
|
-
|
80
|
-
# test from_blob and to_blob
|
81
|
-
def test_from_blob
|
82
|
-
img = Magick::Image.read(IMAGES_DIR+'/Button_0.gif').first
|
83
|
-
blob = nil
|
84
|
-
res = nil
|
85
|
-
assert_nothing_raised { blob = img.to_blob }
|
86
|
-
assert_instance_of(String, blob)
|
87
|
-
assert_nothing_raised { res = Magick::Image.from_blob(blob) }
|
88
|
-
assert_instance_of(Array, res)
|
89
|
-
assert_instance_of(Magick::Image, res[0])
|
90
|
-
assert_equal(img, res[0])
|
91
|
-
end
|
92
|
-
|
93
|
-
def test_ping
|
94
|
-
res = Magick::Image.ping(IMAGES_DIR+'/Button_0.gif')
|
95
|
-
assert_instance_of(Array, res)
|
96
|
-
assert_instance_of(Magick::Image, res[0])
|
97
|
-
assert_equal('GIF', res[0].format)
|
98
|
-
assert_equal(127, res[0].columns)
|
99
|
-
assert_equal(120, res[0].rows)
|
100
|
-
assert_match(/Button_0.gif/, res[0].filename)
|
101
|
-
end
|
102
|
-
|
103
|
-
def test_read_inline
|
104
|
-
img = Magick::Image.read(IMAGES_DIR+'/Button_0.gif').first
|
105
|
-
blob = img.to_blob
|
106
|
-
encoded = [blob].pack('m*')
|
107
|
-
res = Magick::Image.read_inline(encoded)
|
108
|
-
assert_instance_of(Array, res)
|
109
|
-
assert_instance_of(Magick::Image, res[0])
|
110
|
-
assert_equal(img, res[0])
|
111
|
-
end
|
112
|
-
|
113
|
-
def test_spaceship
|
114
|
-
img0 = Magick::Image.read(IMAGES_DIR+'/Button_0.gif').first
|
115
|
-
img1 = Magick::Image.read(IMAGES_DIR+'/Button_1.gif').first
|
116
|
-
sig0 = img0.signature
|
117
|
-
sig1 = img1.signature
|
118
|
-
# since <=> is based on the signature, the images should
|
119
|
-
# have the same relationship to each other as their
|
120
|
-
# signatures have to each other.
|
121
|
-
assert_equal(sig0 <=> sig1, img0 <=> img1)
|
122
|
-
assert_equal(sig1 <=> sig0, img1 <=> img0)
|
123
|
-
assert_equal(img0, img0)
|
124
|
-
assert_not_equal(img0, img1)
|
125
|
-
end
|
126
|
-
|
127
|
-
def test_adaptive_blur
|
128
|
-
assert_nothing_raised do
|
129
|
-
res = @img.adaptive_blur
|
130
|
-
assert_instance_of(Magick::Image, res)
|
131
|
-
end
|
132
|
-
assert_nothing_raised { @img.adaptive_blur(2) }
|
133
|
-
assert_nothing_raised { @img.adaptive_blur(3, 2) }
|
134
|
-
assert_raise(ArgumentError) { @img.adaptive_blur(3, 2, 2) }
|
135
|
-
end
|
136
|
-
|
137
|
-
def test_adaptive_blur_channel
|
138
|
-
assert_nothing_raised do
|
139
|
-
res = @img.adaptive_blur_channel
|
140
|
-
assert_instance_of(Magick::Image, res)
|
141
|
-
end
|
142
|
-
assert_nothing_raised { @img.adaptive_blur_channel(2) }
|
143
|
-
assert_nothing_raised { @img.adaptive_blur_channel(3, 2) }
|
144
|
-
assert_nothing_raised { @img.adaptive_blur_channel(3, 2, Magick::RedChannel) }
|
145
|
-
assert_nothing_raised { @img.adaptive_blur_channel(3, 2, Magick::RedChannel, Magick::BlueChannel) }
|
146
|
-
assert_raise(ArgumentError) { @img.adaptive_blur(3, 2, 2) }
|
147
|
-
end
|
148
|
-
|
149
|
-
def test_adaptive_resize
|
150
|
-
assert_nothing_raised do
|
151
|
-
res = @img.adaptive_resize(10,10)
|
152
|
-
assert_instance_of(Magick::Image, res)
|
153
|
-
end
|
154
|
-
assert_nothing_raised { @img.adaptive_resize(2) }
|
155
|
-
assert_raise(ArgumentError) { @img.adaptive_resize(10,10,10) }
|
156
|
-
assert_raise(ArgumentError) { @img.adaptive_resize }
|
157
|
-
end
|
158
|
-
|
159
|
-
def test_adaptive_sharpen
|
160
|
-
assert_nothing_raised do
|
161
|
-
res = @img.adaptive_sharpen
|
162
|
-
assert_instance_of(Magick::Image, res)
|
163
|
-
end
|
164
|
-
assert_nothing_raised { @img.adaptive_sharpen(2) }
|
165
|
-
assert_nothing_raised { @img.adaptive_sharpen(3, 2) }
|
166
|
-
assert_raise(ArgumentError) { @img.adaptive_sharpen(3, 2, 2) }
|
167
|
-
end
|
168
|
-
|
169
|
-
def test_adaptive_sharpen_channel
|
170
|
-
assert_nothing_raised do
|
171
|
-
res = @img.adaptive_sharpen_channel
|
172
|
-
assert_instance_of(Magick::Image, res)
|
173
|
-
end
|
174
|
-
assert_nothing_raised { @img.adaptive_sharpen_channel(2) }
|
175
|
-
assert_nothing_raised { @img.adaptive_sharpen_channel(3, 2) }
|
176
|
-
assert_nothing_raised { @img.adaptive_sharpen_channel(3, 2, Magick::RedChannel) }
|
177
|
-
assert_nothing_raised { @img.adaptive_sharpen_channel(3, 2, Magick::RedChannel, Magick::BlueChannel) }
|
178
|
-
assert_raise(ArgumentError) { @img.adaptive_sharpen(3, 2, 2) }
|
179
|
-
end
|
180
|
-
|
181
|
-
def test_adaptive_threshold
|
182
|
-
assert_nothing_raised do
|
183
|
-
res = @img.adaptive_threshold
|
184
|
-
assert_instance_of(Magick::Image, res)
|
185
|
-
end
|
186
|
-
assert_nothing_raised { @img.adaptive_threshold(2) }
|
187
|
-
assert_nothing_raised { @img.adaptive_threshold(2,4) }
|
188
|
-
assert_nothing_raised { @img.adaptive_threshold(2,4,1) }
|
189
|
-
assert_raise(ArgumentError) { @img.adaptive_threshold(2,4,1,2) }
|
190
|
-
end
|
191
|
-
|
192
|
-
def test_add_compose_mask
|
193
|
-
mask = Magick::Image.new(20,20)
|
194
|
-
assert_nothing_raised { @img.add_compose_mask(mask) }
|
195
|
-
assert_nothing_raised { @img.delete_compose_mask }
|
196
|
-
assert_nothing_raised { @img.add_compose_mask(mask) }
|
197
|
-
assert_nothing_raised { @img.add_compose_mask(mask) }
|
198
|
-
assert_nothing_raised { @img.delete_compose_mask }
|
199
|
-
assert_nothing_raised { @img.delete_compose_mask }
|
200
|
-
end
|
201
|
-
|
202
|
-
def test_add_noise
|
203
|
-
assert_nothing_raised { @img.add_noise(Magick::UniformNoise) }
|
204
|
-
assert_nothing_raised { @img.add_noise(Magick::GaussianNoise) }
|
205
|
-
assert_nothing_raised { @img.add_noise(Magick::MultiplicativeGaussianNoise) }
|
206
|
-
assert_nothing_raised { @img.add_noise(Magick::ImpulseNoise) }
|
207
|
-
assert_nothing_raised { @img.add_noise(Magick::LaplacianNoise) }
|
208
|
-
assert_nothing_raised { @img.add_noise(Magick::PoissonNoise) }
|
209
|
-
assert_raise(TypeError) { @img.add_noise(0) }
|
210
|
-
end
|
211
|
-
|
212
|
-
def test_add_noise_channel
|
213
|
-
assert_nothing_raised { @img.add_noise_channel(Magick::UniformNoise) }
|
214
|
-
assert_nothing_raised { @img.add_noise_channel(Magick::UniformNoise, Magick::RedChannel) }
|
215
|
-
assert_nothing_raised { @img.add_noise_channel(Magick::GaussianNoise, Magick::BlueChannel) }
|
216
|
-
assert_nothing_raised { @img.add_noise_channel(Magick::ImpulseNoise, Magick::GreenChannel) }
|
217
|
-
assert_nothing_raised { @img.add_noise_channel(Magick::LaplacianNoise, Magick::RedChannel, Magick::GreenChannel) }
|
218
|
-
assert_nothing_raised { @img.add_noise_channel(Magick::PoissonNoise, Magick::RedChannel, Magick::GreenChannel, Magick::BlueChannel) }
|
219
|
-
|
220
|
-
# Not a NoiseType
|
221
|
-
assert_raise(TypeError) { @img.add_noise_channel(1) }
|
222
|
-
# Not a ChannelType
|
223
|
-
assert_raise(TypeError) { @img.add_noise_channel(Magick::UniformNoise, Magick::RedChannel, 1) }
|
224
|
-
# Too few arguments
|
225
|
-
assert_raise(ArgumentError) { @img.add_noise_channel }
|
226
|
-
end
|
227
|
-
|
228
|
-
def add_delete_profile
|
229
|
-
img = Magick::Image.read('cmyk.jpg'),first
|
230
|
-
assert_nothing_raised { img.add_profile('cmyk.icm') }
|
231
|
-
assert_nothing_raised { img.add_profile('srgb.icm') }
|
232
|
-
img.each_profile { |name, value| assert_equal('icc', name) }
|
233
|
-
assert_nothing_raised { img.delete_profile('icc') }
|
234
|
-
end
|
235
|
-
|
236
|
-
def test_affine_matrix
|
237
|
-
affine = Magick::AffineMatrix.new(1, Math::PI/6, Math::PI/6, 1, 0, 0)
|
238
|
-
assert_nothing_raised { @img.affine_transform(affine) }
|
239
|
-
assert_raise(TypeError) { @img.affine_transform(0) }
|
240
|
-
res = @img.affine_transform(affine)
|
241
|
-
assert_instance_of(Magick::Image, res)
|
242
|
-
end
|
243
|
-
|
244
|
-
# test alpha backward compatibility. Image#alpha w/o arguments acts like alpha?
|
245
|
-
def test_alpha_compat
|
246
|
-
assert_nothing_raised { @img.alpha }
|
247
|
-
assert !@img.alpha
|
248
|
-
assert_nothing_raised { @img.alpha Magick::ActivateAlphaChannel }
|
249
|
-
assert @img.alpha
|
250
|
-
end
|
251
|
-
|
252
|
-
def test_alpha
|
253
|
-
assert_nothing_raised { @img.alpha? }
|
254
|
-
assert !@img.alpha?
|
255
|
-
assert_nothing_raised { @img.alpha Magick::ActivateAlphaChannel }
|
256
|
-
assert @img.alpha?
|
257
|
-
assert_nothing_raised { @img.alpha Magick::DeactivateAlphaChannel }
|
258
|
-
assert !@img.alpha?
|
259
|
-
assert_nothing_raised { @img.alpha Magick::ResetAlphaChannel }
|
260
|
-
assert_nothing_raised { @img.alpha Magick::SetAlphaChannel }
|
261
|
-
@img.freeze
|
262
|
-
assert_raise(FreezeError) { @img.alpha Magick::SetAlphaChannel }
|
263
|
-
end
|
264
|
-
|
265
|
-
def test_auto_gamma
|
266
|
-
res = nil
|
267
|
-
assert_nothing_raised { res = @img.auto_gamma_channel }
|
268
|
-
assert_instance_of(Magick::Image, res)
|
269
|
-
assert_not_same(@img, res)
|
270
|
-
assert_nothing_raised { res = @img.auto_gamma_channel Magick::RedChannel }
|
271
|
-
assert_nothing_raised { res = @img.auto_gamma_channel Magick::RedChannel, Magick::BlueChannel }
|
272
|
-
assert_raise(TypeError) { @img.auto_gamma_channel(1) }
|
273
|
-
end
|
274
|
-
|
275
|
-
def test_auto_level
|
276
|
-
res = nil
|
277
|
-
assert_nothing_raised { res = @img.auto_level_channel }
|
278
|
-
assert_instance_of(Magick::Image, res)
|
279
|
-
assert_not_same(@img, res)
|
280
|
-
assert_nothing_raised { res = @img.auto_level_channel Magick::RedChannel }
|
281
|
-
assert_nothing_raised { res = @img.auto_level_channel Magick::RedChannel, Magick::BlueChannel }
|
282
|
-
assert_raise(TypeError) { @img.auto_level_channel(1) }
|
283
|
-
end
|
284
|
-
|
285
|
-
def test_auto_orient
|
286
|
-
assert_nothing_raised do
|
287
|
-
res = @img.auto_orient
|
288
|
-
assert_instance_of(Magick::Image, res)
|
289
|
-
assert_not_same(@img, res)
|
290
|
-
end
|
291
|
-
|
292
|
-
assert_nothing_raised do
|
293
|
-
res = @img.auto_orient!
|
294
|
-
# When not changed, returns nil
|
295
|
-
assert_nil(res)
|
296
|
-
end
|
297
|
-
end
|
298
|
-
|
299
|
-
def test_bilevel_channel
|
300
|
-
assert_raise(ArgumentError) { @img.bilevel_channel }
|
301
|
-
assert_nothing_raised { @img.bilevel_channel(100) }
|
302
|
-
assert_nothing_raised { @img.bilevel_channel(100, Magick::RedChannel) }
|
303
|
-
assert_nothing_raised { @img.bilevel_channel(100, Magick::RedChannel, Magick::BlueChannel, Magick::GreenChannel, Magick::OpacityChannel) }
|
304
|
-
assert_nothing_raised { @img.bilevel_channel(100, Magick::CyanChannel, Magick::MagentaChannel, Magick::YellowChannel, Magick::BlackChannel) }
|
305
|
-
assert_nothing_raised { @img.bilevel_channel(100, Magick::GrayChannel) }
|
306
|
-
assert_nothing_raised { @img.bilevel_channel(100, Magick::AllChannels) }
|
307
|
-
assert_raise(TypeError) { @img.bilevel_channel(100, 2) }
|
308
|
-
res = @img.bilevel_channel(100)
|
309
|
-
assert_instance_of(Magick::Image, res)
|
310
|
-
end
|
311
|
-
|
312
|
-
def test_blend
|
313
|
-
@img2 = Magick::Image.new(20,20) {self.background_color = 'black'}
|
314
|
-
assert_nothing_raised { @img.blend(@img2, 0.25) }
|
315
|
-
res = @img.blend(@img2, 0.25)
|
8
|
+
FreezeError = RUBY_VERSION[/^1\.9|^2/] ? RuntimeError : TypeError
|
9
|
+
|
10
|
+
def setup
|
11
|
+
@img = Magick::Image.new(20, 20)
|
12
|
+
end
|
13
|
+
|
14
|
+
def test_read_inline
|
15
|
+
img = Magick::Image.read(IMAGES_DIR+'/Button_0.gif').first
|
16
|
+
blob = img.to_blob
|
17
|
+
encoded = [blob].pack('m*')
|
18
|
+
res = Magick::Image.read_inline(encoded)
|
19
|
+
assert_instance_of(Array, res)
|
20
|
+
assert_instance_of(Magick::Image, res[0])
|
21
|
+
assert_equal(img, res[0])
|
22
|
+
end
|
23
|
+
|
24
|
+
def test_spaceship
|
25
|
+
img0 = Magick::Image.read(IMAGES_DIR+'/Button_0.gif').first
|
26
|
+
img1 = Magick::Image.read(IMAGES_DIR+'/Button_1.gif').first
|
27
|
+
sig0 = img0.signature
|
28
|
+
sig1 = img1.signature
|
29
|
+
# since <=> is based on the signature, the images should
|
30
|
+
# have the same relationship to each other as their
|
31
|
+
# signatures have to each other.
|
32
|
+
assert_equal(sig0 <=> sig1, img0 <=> img1)
|
33
|
+
assert_equal(sig1 <=> sig0, img1 <=> img0)
|
34
|
+
assert_equal(img0, img0)
|
35
|
+
assert_not_equal(img0, img1)
|
36
|
+
end
|
37
|
+
|
38
|
+
def test_adaptive_blur
|
39
|
+
assert_nothing_raised do
|
40
|
+
res = @img.adaptive_blur
|
316
41
|
assert_instance_of(Magick::Image, res)
|
317
|
-
assert_nothing_raised { @img.blend(@img2, '25%') }
|
318
|
-
assert_nothing_raised { @img.blend(@img2, 0.25, 0.75) }
|
319
|
-
assert_nothing_raised { @img.blend(@img2, '25%', '75%') }
|
320
|
-
assert_nothing_raised { @img.blend(@img2, 0.25, 0.75, Magick::CenterGravity) }
|
321
|
-
assert_nothing_raised { @img.blend(@img2, 0.25, 0.75, Magick::CenterGravity, 10) }
|
322
|
-
assert_nothing_raised { @img.blend(@img2, 0.25, 0.75, Magick::CenterGravity, 10, 10) }
|
323
|
-
assert_raise(ArgumentError) { @img.blend }
|
324
|
-
assert_raise(ArgumentError) { @img.blend(@img2, 'x') }
|
325
|
-
assert_raise(TypeError) { @img.blend(@img2, 0.25, []) }
|
326
|
-
assert_raise(TypeError) { @img.blend(@img2, 0.25, 0.75, 'x') }
|
327
|
-
assert_raise(TypeError) { @img.blend(@img2, 0.25, 0.75, Magick::CenterGravity, 'x') }
|
328
|
-
assert_raise(TypeError) { @img.blend(@img2, 0.25, 0.75, Magick::CenterGravity, 10, []) }
|
329
|
-
|
330
|
-
@img2.destroy!
|
331
|
-
assert_raise(Magick::DestroyedImageError) { @img.blend(@img2, '25%') }
|
332
42
|
end
|
43
|
+
assert_nothing_raised { @img.adaptive_blur(2) }
|
44
|
+
assert_nothing_raised { @img.adaptive_blur(3, 2) }
|
45
|
+
assert_raise(ArgumentError) { @img.adaptive_blur(3, 2, 2) }
|
46
|
+
end
|
333
47
|
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
assert_nothing_raised { @img.blur_channel(1,2, Magick::RedChannel) }
|
339
|
-
assert_nothing_raised { @img.blur_channel(1,2, Magick::RedChannel, Magick::BlueChannel, Magick::GreenChannel, Magick::OpacityChannel) }
|
340
|
-
assert_nothing_raised { @img.blur_channel(1,2, Magick::CyanChannel, Magick::MagentaChannel, Magick::YellowChannel, Magick::BlackChannel) }
|
341
|
-
assert_nothing_raised { @img.blur_channel(1,2, Magick::GrayChannel) }
|
342
|
-
assert_nothing_raised { @img.blur_channel(1,2, Magick::AllChannels) }
|
343
|
-
assert_raise(TypeError) { @img.blur_channel(1,2,2) }
|
344
|
-
res = @img.blur_channel
|
345
|
-
assert_instance_of(Magick::Image, res)
|
48
|
+
def test_adaptive_blur_channel
|
49
|
+
assert_nothing_raised do
|
50
|
+
res = @img.adaptive_blur_channel
|
51
|
+
assert_instance_of(Magick::Image, res)
|
346
52
|
end
|
53
|
+
assert_nothing_raised { @img.adaptive_blur_channel(2) }
|
54
|
+
assert_nothing_raised { @img.adaptive_blur_channel(3, 2) }
|
55
|
+
assert_nothing_raised { @img.adaptive_blur_channel(3, 2, Magick::RedChannel) }
|
56
|
+
assert_nothing_raised { @img.adaptive_blur_channel(3, 2, Magick::RedChannel, Magick::BlueChannel) }
|
57
|
+
assert_raise(ArgumentError) { @img.adaptive_blur(3, 2, 2) }
|
58
|
+
end
|
347
59
|
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
|
352
|
-
assert_raise(ArgumentError) { @img.blur_image(1,2,3) }
|
353
|
-
res = @img.blur_image
|
354
|
-
assert_instance_of(Magick::Image, res)
|
60
|
+
def test_adaptive_resize
|
61
|
+
assert_nothing_raised do
|
62
|
+
res = @img.adaptive_resize(10,10)
|
63
|
+
assert_instance_of(Magick::Image, res)
|
355
64
|
end
|
65
|
+
assert_nothing_raised { @img.adaptive_resize(2) }
|
66
|
+
assert_raise(ArgumentError) { @img.adaptive_resize(10,10,10) }
|
67
|
+
assert_raise(ArgumentError) { @img.adaptive_resize }
|
68
|
+
end
|
356
69
|
|
357
|
-
|
358
|
-
|
359
|
-
|
360
|
-
|
361
|
-
assert_nothing_raised { @img.black_threshold(50, 50, 50) }
|
362
|
-
assert_nothing_raised { @img.black_threshold(50, 50, 50, 50) }
|
363
|
-
assert_raise(ArgumentError) { @img.black_threshold(50, 50, 50, 50, 50) }
|
364
|
-
res = @img.black_threshold(50)
|
365
|
-
assert_instance_of(Magick::Image, res)
|
70
|
+
def test_adaptive_sharpen
|
71
|
+
assert_nothing_raised do
|
72
|
+
res = @img.adaptive_sharpen
|
73
|
+
assert_instance_of(Magick::Image, res)
|
366
74
|
end
|
75
|
+
assert_nothing_raised { @img.adaptive_sharpen(2) }
|
76
|
+
assert_nothing_raised { @img.adaptive_sharpen(3, 2) }
|
77
|
+
assert_raise(ArgumentError) { @img.adaptive_sharpen(3, 2, 2) }
|
78
|
+
end
|
367
79
|
|
368
|
-
|
369
|
-
|
370
|
-
|
371
|
-
|
372
|
-
assert_instance_of(Magick::Image, res)
|
373
|
-
@img.freeze
|
374
|
-
assert_raise(FreezeError) { @img.border!(2,2, 'red') }
|
80
|
+
def test_adaptive_sharpen_channel
|
81
|
+
assert_nothing_raised do
|
82
|
+
res = @img.adaptive_sharpen_channel
|
83
|
+
assert_instance_of(Magick::Image, res)
|
375
84
|
end
|
85
|
+
assert_nothing_raised { @img.adaptive_sharpen_channel(2) }
|
86
|
+
assert_nothing_raised { @img.adaptive_sharpen_channel(3, 2) }
|
87
|
+
assert_nothing_raised { @img.adaptive_sharpen_channel(3, 2, Magick::RedChannel) }
|
88
|
+
assert_nothing_raised { @img.adaptive_sharpen_channel(3, 2, Magick::RedChannel, Magick::BlueChannel) }
|
89
|
+
assert_raise(ArgumentError) { @img.adaptive_sharpen(3, 2, 2) }
|
90
|
+
end
|
376
91
|
|
377
|
-
|
378
|
-
|
379
|
-
|
380
|
-
|
381
|
-
res = @img.change_geometry('100x100') { 1 }
|
382
|
-
assert_equal(1, res)
|
383
|
-
end
|
384
|
-
assert_raise(ArgumentError) { @img.change_geometry([]) }
|
92
|
+
def test_adaptive_threshold
|
93
|
+
assert_nothing_raised do
|
94
|
+
res = @img.adaptive_threshold
|
95
|
+
assert_instance_of(Magick::Image, res)
|
385
96
|
end
|
386
|
-
|
387
|
-
|
97
|
+
assert_nothing_raised { @img.adaptive_threshold(2) }
|
98
|
+
assert_nothing_raised { @img.adaptive_threshold(2,4) }
|
99
|
+
assert_nothing_raised { @img.adaptive_threshold(2,4,1) }
|
100
|
+
assert_raise(ArgumentError) { @img.adaptive_threshold(2,4,1,2) }
|
101
|
+
end
|
102
|
+
|
103
|
+
def test_add_compose_mask
|
104
|
+
mask = Magick::Image.new(20,20)
|
105
|
+
assert_nothing_raised { @img.add_compose_mask(mask) }
|
106
|
+
assert_nothing_raised { @img.delete_compose_mask }
|
107
|
+
assert_nothing_raised { @img.add_compose_mask(mask) }
|
108
|
+
assert_nothing_raised { @img.add_compose_mask(mask) }
|
109
|
+
assert_nothing_raised { @img.delete_compose_mask }
|
110
|
+
assert_nothing_raised { @img.delete_compose_mask }
|
111
|
+
end
|
112
|
+
|
113
|
+
def test_add_noise
|
114
|
+
assert_nothing_raised { @img.add_noise(Magick::UniformNoise) }
|
115
|
+
assert_nothing_raised { @img.add_noise(Magick::GaussianNoise) }
|
116
|
+
assert_nothing_raised { @img.add_noise(Magick::MultiplicativeGaussianNoise) }
|
117
|
+
assert_nothing_raised { @img.add_noise(Magick::ImpulseNoise) }
|
118
|
+
assert_nothing_raised { @img.add_noise(Magick::LaplacianNoise) }
|
119
|
+
assert_nothing_raised { @img.add_noise(Magick::PoissonNoise) }
|
120
|
+
assert_raise(TypeError) { @img.add_noise(0) }
|
121
|
+
end
|
122
|
+
|
123
|
+
def test_add_noise_channel
|
124
|
+
assert_nothing_raised { @img.add_noise_channel(Magick::UniformNoise) }
|
125
|
+
assert_nothing_raised { @img.add_noise_channel(Magick::UniformNoise, Magick::RedChannel) }
|
126
|
+
assert_nothing_raised { @img.add_noise_channel(Magick::GaussianNoise, Magick::BlueChannel) }
|
127
|
+
assert_nothing_raised { @img.add_noise_channel(Magick::ImpulseNoise, Magick::GreenChannel) }
|
128
|
+
assert_nothing_raised { @img.add_noise_channel(Magick::LaplacianNoise, Magick::RedChannel, Magick::GreenChannel) }
|
129
|
+
assert_nothing_raised { @img.add_noise_channel(Magick::PoissonNoise, Magick::RedChannel, Magick::GreenChannel, Magick::BlueChannel) }
|
130
|
+
|
131
|
+
# Not a NoiseType
|
132
|
+
assert_raise(TypeError) { @img.add_noise_channel(1) }
|
133
|
+
# Not a ChannelType
|
134
|
+
assert_raise(TypeError) { @img.add_noise_channel(Magick::UniformNoise, Magick::RedChannel, 1) }
|
135
|
+
# Too few arguments
|
136
|
+
assert_raise(ArgumentError) { @img.add_noise_channel }
|
137
|
+
end
|
138
|
+
|
139
|
+
def add_delete_profile
|
140
|
+
img = Magick::Image.read('cmyk.jpg'),first
|
141
|
+
assert_nothing_raised { img.add_profile('cmyk.icm') }
|
142
|
+
assert_nothing_raised { img.add_profile('srgb.icm') }
|
143
|
+
img.each_profile { |name, value| assert_equal('icc', name) }
|
144
|
+
assert_nothing_raised { img.delete_profile('icc') }
|
145
|
+
end
|
146
|
+
|
147
|
+
def test_affine_matrix
|
148
|
+
affine = Magick::AffineMatrix.new(1, Math::PI/6, Math::PI/6, 1, 0, 0)
|
149
|
+
assert_nothing_raised { @img.affine_transform(affine) }
|
150
|
+
assert_raise(TypeError) { @img.affine_transform(0) }
|
151
|
+
res = @img.affine_transform(affine)
|
152
|
+
assert_instance_of(Magick::Image, res)
|
153
|
+
end
|
154
|
+
|
155
|
+
# test alpha backward compatibility. Image#alpha w/o arguments acts like alpha?
|
156
|
+
def test_alpha_compat
|
157
|
+
assert_nothing_raised { @img.alpha }
|
158
|
+
assert !@img.alpha
|
159
|
+
assert_nothing_raised { @img.alpha Magick::ActivateAlphaChannel }
|
160
|
+
assert @img.alpha
|
161
|
+
end
|
162
|
+
|
163
|
+
def test_alpha
|
164
|
+
assert_nothing_raised { @img.alpha? }
|
165
|
+
assert !@img.alpha?
|
166
|
+
assert_nothing_raised { @img.alpha Magick::ActivateAlphaChannel }
|
167
|
+
assert @img.alpha?
|
168
|
+
assert_nothing_raised { @img.alpha Magick::DeactivateAlphaChannel }
|
169
|
+
assert !@img.alpha?
|
170
|
+
assert_nothing_raised { @img.alpha Magick::ResetAlphaChannel }
|
171
|
+
assert_nothing_raised { @img.alpha Magick::SetAlphaChannel }
|
172
|
+
@img.freeze
|
173
|
+
assert_raise(FreezeError) { @img.alpha Magick::SetAlphaChannel }
|
174
|
+
end
|
175
|
+
|
176
|
+
def test_auto_gamma
|
177
|
+
res = nil
|
178
|
+
assert_nothing_raised { res = @img.auto_gamma_channel }
|
179
|
+
assert_instance_of(Magick::Image, res)
|
180
|
+
assert_not_same(@img, res)
|
181
|
+
assert_nothing_raised { res = @img.auto_gamma_channel Magick::RedChannel }
|
182
|
+
assert_nothing_raised { res = @img.auto_gamma_channel Magick::RedChannel, Magick::BlueChannel }
|
183
|
+
assert_raise(TypeError) { @img.auto_gamma_channel(1) }
|
184
|
+
end
|
185
|
+
|
186
|
+
def test_auto_level
|
187
|
+
res = nil
|
188
|
+
assert_nothing_raised { res = @img.auto_level_channel }
|
189
|
+
assert_instance_of(Magick::Image, res)
|
190
|
+
assert_not_same(@img, res)
|
191
|
+
assert_nothing_raised { res = @img.auto_level_channel Magick::RedChannel }
|
192
|
+
assert_nothing_raised { res = @img.auto_level_channel Magick::RedChannel, Magick::BlueChannel }
|
193
|
+
assert_raise(TypeError) { @img.auto_level_channel(1) }
|
194
|
+
end
|
195
|
+
|
196
|
+
def test_auto_orient
|
197
|
+
assert_nothing_raised do
|
198
|
+
res = @img.auto_orient
|
199
|
+
assert_instance_of(Magick::Image, res)
|
200
|
+
assert_not_same(@img, res)
|
201
|
+
end
|
202
|
+
|
203
|
+
assert_nothing_raised do
|
204
|
+
res = @img.auto_orient!
|
205
|
+
# When not changed, returns nil
|
206
|
+
assert_nil(res)
|
207
|
+
end
|
208
|
+
end
|
209
|
+
|
210
|
+
def test_bilevel_channel
|
211
|
+
assert_raise(ArgumentError) { @img.bilevel_channel }
|
212
|
+
assert_nothing_raised { @img.bilevel_channel(100) }
|
213
|
+
assert_nothing_raised { @img.bilevel_channel(100, Magick::RedChannel) }
|
214
|
+
assert_nothing_raised { @img.bilevel_channel(100, Magick::RedChannel, Magick::BlueChannel, Magick::GreenChannel, Magick::OpacityChannel) }
|
215
|
+
assert_nothing_raised { @img.bilevel_channel(100, Magick::CyanChannel, Magick::MagentaChannel, Magick::YellowChannel, Magick::BlackChannel) }
|
216
|
+
assert_nothing_raised { @img.bilevel_channel(100, Magick::GrayChannel) }
|
217
|
+
assert_nothing_raised { @img.bilevel_channel(100, Magick::AllChannels) }
|
218
|
+
assert_raise(TypeError) { @img.bilevel_channel(100, 2) }
|
219
|
+
res = @img.bilevel_channel(100)
|
220
|
+
assert_instance_of(Magick::Image, res)
|
221
|
+
end
|
222
|
+
|
223
|
+
def test_blend
|
224
|
+
@img2 = Magick::Image.new(20,20) {self.background_color = 'black'}
|
225
|
+
assert_nothing_raised { @img.blend(@img2, 0.25) }
|
226
|
+
res = @img.blend(@img2, 0.25)
|
227
|
+
assert_instance_of(Magick::Image, res)
|
228
|
+
assert_nothing_raised { @img.blend(@img2, '25%') }
|
229
|
+
assert_nothing_raised { @img.blend(@img2, 0.25, 0.75) }
|
230
|
+
assert_nothing_raised { @img.blend(@img2, '25%', '75%') }
|
231
|
+
assert_nothing_raised { @img.blend(@img2, 0.25, 0.75, Magick::CenterGravity) }
|
232
|
+
assert_nothing_raised { @img.blend(@img2, 0.25, 0.75, Magick::CenterGravity, 10) }
|
233
|
+
assert_nothing_raised { @img.blend(@img2, 0.25, 0.75, Magick::CenterGravity, 10, 10) }
|
234
|
+
assert_raise(ArgumentError) { @img.blend }
|
235
|
+
assert_raise(ArgumentError) { @img.blend(@img2, 'x') }
|
236
|
+
assert_raise(TypeError) { @img.blend(@img2, 0.25, []) }
|
237
|
+
assert_raise(TypeError) { @img.blend(@img2, 0.25, 0.75, 'x') }
|
238
|
+
assert_raise(TypeError) { @img.blend(@img2, 0.25, 0.75, Magick::CenterGravity, 'x') }
|
239
|
+
assert_raise(TypeError) { @img.blend(@img2, 0.25, 0.75, Magick::CenterGravity, 10, []) }
|
240
|
+
|
241
|
+
@img2.destroy!
|
242
|
+
assert_raise(Magick::DestroyedImageError) { @img.blend(@img2, '25%') }
|
243
|
+
end
|
244
|
+
|
245
|
+
def test_blur_channel
|
246
|
+
assert_nothing_raised { @img.blur_channel }
|
247
|
+
assert_nothing_raised { @img.blur_channel(1) }
|
248
|
+
assert_nothing_raised { @img.blur_channel(1,2) }
|
249
|
+
assert_nothing_raised { @img.blur_channel(1,2, Magick::RedChannel) }
|
250
|
+
assert_nothing_raised { @img.blur_channel(1,2, Magick::RedChannel, Magick::BlueChannel, Magick::GreenChannel, Magick::OpacityChannel) }
|
251
|
+
assert_nothing_raised { @img.blur_channel(1,2, Magick::CyanChannel, Magick::MagentaChannel, Magick::YellowChannel, Magick::BlackChannel) }
|
252
|
+
assert_nothing_raised { @img.blur_channel(1,2, Magick::GrayChannel) }
|
253
|
+
assert_nothing_raised { @img.blur_channel(1,2, Magick::AllChannels) }
|
254
|
+
assert_raise(TypeError) { @img.blur_channel(1,2,2) }
|
255
|
+
res = @img.blur_channel
|
256
|
+
assert_instance_of(Magick::Image, res)
|
257
|
+
end
|
258
|
+
|
259
|
+
def test_blur_image
|
260
|
+
assert_nothing_raised { @img.blur_image }
|
261
|
+
assert_nothing_raised { @img.blur_image(1) }
|
262
|
+
assert_nothing_raised { @img.blur_image(1,2) }
|
263
|
+
assert_raise(ArgumentError) { @img.blur_image(1,2,3) }
|
264
|
+
res = @img.blur_image
|
265
|
+
assert_instance_of(Magick::Image, res)
|
266
|
+
end
|
267
|
+
|
268
|
+
def test_black_threshold
|
269
|
+
assert_raise(ArgumentError) { @img.black_threshold }
|
270
|
+
assert_nothing_raised { @img.black_threshold(50) }
|
271
|
+
assert_nothing_raised { @img.black_threshold(50, 50) }
|
272
|
+
assert_nothing_raised { @img.black_threshold(50, 50, 50) }
|
273
|
+
assert_nothing_raised { @img.black_threshold(50, 50, 50, 50) }
|
274
|
+
assert_raise(ArgumentError) { @img.black_threshold(50, 50, 50, 50, 50) }
|
275
|
+
res = @img.black_threshold(50)
|
276
|
+
assert_instance_of(Magick::Image, res)
|
277
|
+
end
|
278
|
+
|
279
|
+
def test_border
|
280
|
+
assert_nothing_raised { @img.border(2, 2, 'red') }
|
281
|
+
assert_nothing_raised { @img.border!(2, 2, 'red') }
|
282
|
+
res = @img.border(2,2, 'red')
|
283
|
+
assert_instance_of(Magick::Image, res)
|
284
|
+
@img.freeze
|
285
|
+
assert_raise(FreezeError) { @img.border!(2,2, 'red') }
|
286
|
+
end
|
287
|
+
|
288
|
+
def test_change_geometry
|
289
|
+
assert_raise(ArgumentError) { @img.change_geometry('sss') }
|
290
|
+
assert_raise(LocalJumpError) { @img.change_geometry('100x100') }
|
291
|
+
assert_nothing_raised do
|
292
|
+
res = @img.change_geometry('100x100') { 1 }
|
293
|
+
assert_equal(1, res)
|
294
|
+
end
|
295
|
+
assert_raise(ArgumentError) { @img.change_geometry([]) }
|
296
|
+
end
|
297
|
+
|
298
|
+
def test_changed?
|
388
299
|
# assert_block { !@img.changed? }
|
389
300
|
# @img.pixel_color(0,0,'red')
|
390
301
|
# assert_block { @img.changed? }
|
302
|
+
end
|
303
|
+
|
304
|
+
def test_channel
|
305
|
+
assert_nothing_raised { @img.channel(Magick::RedChannel) }
|
306
|
+
assert_nothing_raised { @img.channel(Magick::BlueChannel) }
|
307
|
+
assert_nothing_raised { @img.channel(Magick::GreenChannel) }
|
308
|
+
assert_nothing_raised { @img.channel(Magick::OpacityChannel) }
|
309
|
+
assert_nothing_raised { @img.channel(Magick::MagentaChannel) }
|
310
|
+
assert_nothing_raised { @img.channel(Magick::CyanChannel) }
|
311
|
+
assert_nothing_raised { @img.channel(Magick::YellowChannel) }
|
312
|
+
assert_nothing_raised { @img.channel(Magick::BlackChannel) }
|
313
|
+
assert_nothing_raised { @img.channel(Magick::GrayChannel) }
|
314
|
+
assert_nothing_raised { @img.channel(Magick::AlphaChannel) }
|
315
|
+
assert_nothing_raised { @img.channel(Magick::DefaultChannels) }
|
316
|
+
assert_nothing_raised { @img.channel(Magick::HueChannel) }
|
317
|
+
assert_nothing_raised { @img.channel(Magick::LuminosityChannel) }
|
318
|
+
assert_nothing_raised { @img.channel(Magick::SaturationChannel) }
|
319
|
+
assert_instance_of(Magick::Image, @img.channel(Magick::RedChannel))
|
320
|
+
assert_raise(TypeError) { @img.channel(2) }
|
321
|
+
end
|
322
|
+
|
323
|
+
def test_channel_depth
|
324
|
+
assert_nothing_raised { @img.channel_depth }
|
325
|
+
assert_nothing_raised { @img.channel_depth(Magick::RedChannel) }
|
326
|
+
assert_nothing_raised { @img.channel_depth(Magick::RedChannel, Magick::BlueChannel) }
|
327
|
+
assert_nothing_raised { @img.channel_depth(Magick::GreenChannel, Magick::OpacityChannel) }
|
328
|
+
assert_nothing_raised { @img.channel_depth(Magick::MagentaChannel, Magick::CyanChannel) }
|
329
|
+
assert_nothing_raised { @img.channel_depth(Magick::CyanChannel, Magick::BlackChannel) }
|
330
|
+
assert_nothing_raised { @img.channel_depth(Magick::GrayChannel) }
|
331
|
+
assert_raise(TypeError) { @img.channel_depth(2) }
|
332
|
+
assert_instance_of(Fixnum, @img.channel_depth(Magick::RedChannel))
|
333
|
+
end
|
334
|
+
|
335
|
+
def test_channel_extrema
|
336
|
+
assert_nothing_raised do
|
337
|
+
res = @img.channel_extrema
|
338
|
+
assert_instance_of(Array, res)
|
339
|
+
assert_equal(2, res.length)
|
340
|
+
assert_kind_of(Integer, res[0])
|
341
|
+
assert_kind_of(Integer, res[1])
|
342
|
+
end
|
343
|
+
assert_nothing_raised { @img.channel_extrema(Magick::RedChannel) }
|
344
|
+
assert_nothing_raised { @img.channel_extrema(Magick::RedChannel, Magick::BlueChannel) }
|
345
|
+
assert_nothing_raised { @img.channel_extrema(Magick::GreenChannel, Magick::OpacityChannel) }
|
346
|
+
assert_nothing_raised { @img.channel_extrema(Magick::MagentaChannel, Magick::CyanChannel) }
|
347
|
+
assert_nothing_raised { @img.channel_extrema(Magick::CyanChannel, Magick::BlackChannel) }
|
348
|
+
assert_nothing_raised { @img.channel_extrema(Magick::GrayChannel) }
|
349
|
+
assert_raise(TypeError) { @img.channel_extrema(2) }
|
350
|
+
end
|
351
|
+
|
352
|
+
def test_channel_mean
|
353
|
+
assert_nothing_raised do
|
354
|
+
res = @img.channel_mean
|
355
|
+
assert_instance_of(Array, res)
|
356
|
+
assert_equal(2, res.length)
|
357
|
+
assert_instance_of(Float, res[0])
|
358
|
+
assert_instance_of(Float, res[1])
|
359
|
+
end
|
360
|
+
assert_nothing_raised { @img.channel_mean(Magick::RedChannel) }
|
361
|
+
assert_nothing_raised { @img.channel_mean(Magick::RedChannel, Magick::BlueChannel) }
|
362
|
+
assert_nothing_raised { @img.channel_mean(Magick::GreenChannel, Magick::OpacityChannel) }
|
363
|
+
assert_nothing_raised { @img.channel_mean(Magick::MagentaChannel, Magick::CyanChannel) }
|
364
|
+
assert_nothing_raised { @img.channel_mean(Magick::CyanChannel, Magick::BlackChannel) }
|
365
|
+
assert_nothing_raised { @img.channel_mean(Magick::GrayChannel) }
|
366
|
+
assert_raise(TypeError) { @img.channel_mean(2) }
|
367
|
+
end
|
368
|
+
|
369
|
+
def test_charcoal
|
370
|
+
assert_nothing_raised do
|
371
|
+
res = @img.charcoal
|
372
|
+
assert_instance_of(Magick::Image, res)
|
391
373
|
end
|
374
|
+
assert_nothing_raised { @img.charcoal(1.0) }
|
375
|
+
assert_nothing_raised { @img.charcoal(1.0, 2.0) }
|
376
|
+
assert_raise(ArgumentError) { @img.charcoal(1.0, 2.0, 3.0) }
|
377
|
+
end
|
392
378
|
|
393
|
-
|
394
|
-
|
395
|
-
|
396
|
-
|
397
|
-
assert_nothing_raised { @img.channel(Magick::OpacityChannel) }
|
398
|
-
assert_nothing_raised { @img.channel(Magick::MagentaChannel) }
|
399
|
-
assert_nothing_raised { @img.channel(Magick::CyanChannel) }
|
400
|
-
assert_nothing_raised { @img.channel(Magick::YellowChannel) }
|
401
|
-
assert_nothing_raised { @img.channel(Magick::BlackChannel) }
|
402
|
-
assert_nothing_raised { @img.channel(Magick::GrayChannel) }
|
403
|
-
assert_nothing_raised { @img.channel(Magick::AlphaChannel) }
|
404
|
-
assert_nothing_raised { @img.channel(Magick::DefaultChannels) }
|
405
|
-
assert_nothing_raised { @img.channel(Magick::HueChannel) }
|
406
|
-
assert_nothing_raised { @img.channel(Magick::LuminosityChannel) }
|
407
|
-
assert_nothing_raised { @img.channel(Magick::SaturationChannel) }
|
408
|
-
assert_instance_of(Magick::Image, @img.channel(Magick::RedChannel))
|
409
|
-
assert_raise(TypeError) { @img.channel(2) }
|
410
|
-
end
|
411
|
-
|
412
|
-
def test_channel_depth
|
413
|
-
assert_nothing_raised { @img.channel_depth }
|
414
|
-
assert_nothing_raised { @img.channel_depth(Magick::RedChannel) }
|
415
|
-
assert_nothing_raised { @img.channel_depth(Magick::RedChannel, Magick::BlueChannel) }
|
416
|
-
assert_nothing_raised { @img.channel_depth(Magick::GreenChannel, Magick::OpacityChannel) }
|
417
|
-
assert_nothing_raised { @img.channel_depth(Magick::MagentaChannel, Magick::CyanChannel) }
|
418
|
-
assert_nothing_raised { @img.channel_depth(Magick::CyanChannel, Magick::BlackChannel) }
|
419
|
-
assert_nothing_raised { @img.channel_depth(Magick::GrayChannel) }
|
420
|
-
assert_raise(TypeError) { @img.channel_depth(2) }
|
421
|
-
assert_instance_of(Fixnum, @img.channel_depth(Magick::RedChannel))
|
422
|
-
end
|
423
|
-
|
424
|
-
def test_channel_extrema
|
425
|
-
assert_nothing_raised do
|
426
|
-
res = @img.channel_extrema
|
427
|
-
assert_instance_of(Array, res)
|
428
|
-
assert_equal(2, res.length)
|
429
|
-
assert_kind_of(Integer, res[0])
|
430
|
-
assert_kind_of(Integer, res[1])
|
431
|
-
end
|
432
|
-
assert_nothing_raised { @img.channel_extrema(Magick::RedChannel) }
|
433
|
-
assert_nothing_raised { @img.channel_extrema(Magick::RedChannel, Magick::BlueChannel) }
|
434
|
-
assert_nothing_raised { @img.channel_extrema(Magick::GreenChannel, Magick::OpacityChannel) }
|
435
|
-
assert_nothing_raised { @img.channel_extrema(Magick::MagentaChannel, Magick::CyanChannel) }
|
436
|
-
assert_nothing_raised { @img.channel_extrema(Magick::CyanChannel, Magick::BlackChannel) }
|
437
|
-
assert_nothing_raised { @img.channel_extrema(Magick::GrayChannel) }
|
438
|
-
assert_raise(TypeError) { @img.channel_extrema(2) }
|
439
|
-
end
|
440
|
-
|
441
|
-
def test_channel_mean
|
442
|
-
assert_nothing_raised do
|
443
|
-
res = @img.channel_mean
|
444
|
-
assert_instance_of(Array, res)
|
445
|
-
assert_equal(2, res.length)
|
446
|
-
assert_instance_of(Float, res[0])
|
447
|
-
assert_instance_of(Float, res[1])
|
448
|
-
end
|
449
|
-
assert_nothing_raised { @img.channel_mean(Magick::RedChannel) }
|
450
|
-
assert_nothing_raised { @img.channel_mean(Magick::RedChannel, Magick::BlueChannel) }
|
451
|
-
assert_nothing_raised { @img.channel_mean(Magick::GreenChannel, Magick::OpacityChannel) }
|
452
|
-
assert_nothing_raised { @img.channel_mean(Magick::MagentaChannel, Magick::CyanChannel) }
|
453
|
-
assert_nothing_raised { @img.channel_mean(Magick::CyanChannel, Magick::BlackChannel) }
|
454
|
-
assert_nothing_raised { @img.channel_mean(Magick::GrayChannel) }
|
455
|
-
assert_raise(TypeError) { @img.channel_mean(2) }
|
456
|
-
end
|
457
|
-
|
458
|
-
def test_charcoal
|
459
|
-
assert_nothing_raised do
|
460
|
-
res = @img.charcoal
|
461
|
-
assert_instance_of(Magick::Image, res)
|
462
|
-
end
|
463
|
-
assert_nothing_raised { @img.charcoal(1.0) }
|
464
|
-
assert_nothing_raised { @img.charcoal(1.0, 2.0) }
|
465
|
-
assert_raise(ArgumentError) { @img.charcoal(1.0, 2.0, 3.0) }
|
466
|
-
end
|
467
|
-
|
468
|
-
def test_chop
|
469
|
-
assert_nothing_raised do
|
470
|
-
res = @img.chop(10, 10, 10, 10)
|
471
|
-
assert_instance_of(Magick::Image, res)
|
472
|
-
end
|
473
|
-
end
|
474
|
-
|
475
|
-
def test_clone
|
476
|
-
assert_nothing_raised do
|
477
|
-
res = @img.clone
|
478
|
-
assert_instance_of(Magick::Image, res)
|
479
|
-
assert_equal(res, @img)
|
480
|
-
end
|
481
|
-
res = @img.clone
|
482
|
-
assert_equal(res.frozen?, @img.frozen?)
|
483
|
-
@img.freeze
|
484
|
-
res = @img.clone
|
485
|
-
assert_equal(res.frozen?, @img.frozen?)
|
486
|
-
end
|
487
|
-
|
488
|
-
def test_clut_channel
|
489
|
-
img = Magick::Image.new(20,20) {self.colorspace = Magick::GRAYColorspace}
|
490
|
-
clut = Magick::Image.new(20,1) {self.background_color = 'red'}
|
491
|
-
res = nil
|
492
|
-
assert_nothing_raised {res = img.clut_channel(clut)}
|
493
|
-
assert_same(res, img)
|
494
|
-
assert_nothing_raised { img.clut_channel(clut, Magick::RedChannel) }
|
495
|
-
assert_nothing_raised { img.clut_channel(clut, Magick::RedChannel, Magick::BlueChannel) }
|
496
|
-
assert_raises(ArgumentError) { img.clut_channel(clut, 1, Magick::RedChannel) }
|
497
|
-
end
|
498
|
-
|
499
|
-
def test_color_fill_to_border
|
500
|
-
assert_raise(ArgumentError) { @img.color_fill_to_border(-1, 1, 'red') }
|
501
|
-
assert_raise(ArgumentError) { @img.color_fill_to_border(1, 100, 'red') }
|
502
|
-
assert_nothing_raised do
|
503
|
-
res = @img.color_fill_to_border(@img.columns/2, @img.rows/2, 'red')
|
504
|
-
assert_instance_of(Magick::Image, res)
|
505
|
-
end
|
506
|
-
pixel = Magick::Pixel.new(Magick::QuantumRange)
|
507
|
-
assert_nothing_raised { @img.color_fill_to_border(@img.columns/2, @img.rows/2, pixel) }
|
508
|
-
end
|
509
|
-
|
510
|
-
def test_color_floodfill
|
511
|
-
assert_raise(ArgumentError) { @img.color_floodfill(-1, 1, 'red') }
|
512
|
-
assert_raise(ArgumentError) { @img.color_floodfill(1, 100, 'red') }
|
513
|
-
assert_nothing_raised do
|
514
|
-
res = @img.color_floodfill(@img.columns/2, @img.rows/2, 'red')
|
515
|
-
assert_instance_of(Magick::Image, res)
|
516
|
-
end
|
517
|
-
pixel = Magick::Pixel.new(Magick::QuantumRange)
|
518
|
-
assert_nothing_raised { @img.color_floodfill(@img.columns/2, @img.rows/2, pixel) }
|
519
|
-
end
|
520
|
-
|
521
|
-
def test_color_histogram
|
522
|
-
assert_nothing_raised do
|
523
|
-
res = @img.color_histogram
|
524
|
-
assert_instance_of(Hash, res)
|
525
|
-
end
|
526
|
-
end
|
527
|
-
|
528
|
-
def test_colorize
|
529
|
-
assert_nothing_raised do
|
530
|
-
res = @img.colorize(0.25, 0.25, 0.25, 'red')
|
531
|
-
assert_instance_of(Magick::Image, res)
|
532
|
-
end
|
533
|
-
assert_nothing_raised { @img.colorize(0.25, 0.25, 0.25, 0.25, 'red') }
|
534
|
-
pixel = Magick::Pixel.new(Magick::QuantumRange)
|
535
|
-
assert_nothing_raised { @img.colorize(0.25, 0.25, 0.25, pixel) }
|
536
|
-
assert_nothing_raised { @img.colorize(0.25, 0.25, 0.25, 0.25, pixel) }
|
537
|
-
assert_raise(ArgumentError) { @img.colorize }
|
538
|
-
assert_raise(ArgumentError) { @img.colorize(0.25) }
|
539
|
-
assert_raise(ArgumentError) { @img.colorize(0.25, 0.25) }
|
540
|
-
assert_raise(ArgumentError) { @img.colorize(0.25, 0.25, 0.25) }
|
541
|
-
assert_raise(ArgumentError) { @img.colorize(0.25, 0.25, 0.25, 'X') }
|
542
|
-
# last argument must be a color name or pixel
|
543
|
-
assert_raise(TypeError) { @img.colorize(0.25, 0.25, 0.25, 0.25) }
|
544
|
-
assert_raise(ArgumentError) { @img.colorize(0.25, 0.25, 0.25, 0.25, 'X') }
|
545
|
-
assert_raise(TypeError) { @img.colorize(0.25, 0.25, 0.25, 0.25, [2]) }
|
546
|
-
end
|
547
|
-
|
548
|
-
def test_colormap
|
549
|
-
# IndexError b/c @img is DirectClass
|
550
|
-
assert_raise(IndexError) { @img.colormap(0) }
|
551
|
-
# Read PseudoClass image
|
552
|
-
pc_img = Magick::Image.read(IMAGES_DIR+'/Button_0.gif').first
|
553
|
-
assert_nothing_raised { pc_img.colormap(0) }
|
554
|
-
ncolors = pc_img.colors
|
555
|
-
assert_raise(IndexError) { pc_img.colormap(ncolors+1) }
|
556
|
-
assert_raise(IndexError) { pc_img.colormap(-1) }
|
557
|
-
assert_nothing_raised { pc_img.colormap(ncolors-1) }
|
558
|
-
res = pc_img.colormap(0)
|
559
|
-
assert_instance_of(String, res)
|
560
|
-
|
561
|
-
#test 'set' operation
|
562
|
-
assert_nothing_raised do
|
563
|
-
old_color = pc_img.colormap(0)
|
564
|
-
res = pc_img.colormap(0, 'red')
|
565
|
-
assert_equal(old_color, res)
|
566
|
-
res = pc_img.colormap(0)
|
567
|
-
assert_equal('red', res)
|
568
|
-
end
|
569
|
-
pixel = Magick::Pixel.new(Magick::QuantumRange)
|
570
|
-
assert_nothing_raised { pc_img.colormap(0, pixel) }
|
571
|
-
assert_raise(TypeError) { pc_img.colormap(0, [2]) }
|
572
|
-
pc_img.freeze
|
573
|
-
assert_raise(FreezeError) { pc_img.colormap(0, 'red') }
|
574
|
-
end
|
575
|
-
|
576
|
-
def test_color_point
|
577
|
-
assert_nothing_raised do
|
578
|
-
res = @img.color_point(0, 0, 'red')
|
579
|
-
assert_instance_of(Magick::Image, res)
|
580
|
-
assert_not_same(@img, res)
|
581
|
-
end
|
582
|
-
pixel = Magick::Pixel.new(Magick::QuantumRange)
|
583
|
-
assert_nothing_raised { @img.color_point(0, 0, pixel) }
|
379
|
+
def test_chop
|
380
|
+
assert_nothing_raised do
|
381
|
+
res = @img.chop(10, 10, 10, 10)
|
382
|
+
assert_instance_of(Magick::Image, res)
|
584
383
|
end
|
384
|
+
end
|
585
385
|
|
586
|
-
|
587
|
-
|
588
|
-
|
589
|
-
|
590
|
-
|
591
|
-
|
592
|
-
|
593
|
-
|
594
|
-
|
595
|
-
|
596
|
-
|
386
|
+
def test_clone
|
387
|
+
assert_nothing_raised do
|
388
|
+
res = @img.clone
|
389
|
+
assert_instance_of(Magick::Image, res)
|
390
|
+
assert_equal(res, @img)
|
391
|
+
end
|
392
|
+
res = @img.clone
|
393
|
+
assert_equal(res.frozen?, @img.frozen?)
|
394
|
+
@img.freeze
|
395
|
+
res = @img.clone
|
396
|
+
assert_equal(res.frozen?, @img.frozen?)
|
397
|
+
end
|
398
|
+
|
399
|
+
def test_clut_channel
|
400
|
+
img = Magick::Image.new(20,20) {self.colorspace = Magick::GRAYColorspace}
|
401
|
+
clut = Magick::Image.new(20,1) {self.background_color = 'red'}
|
402
|
+
res = nil
|
403
|
+
assert_nothing_raised {res = img.clut_channel(clut)}
|
404
|
+
assert_same(res, img)
|
405
|
+
assert_nothing_raised { img.clut_channel(clut, Magick::RedChannel) }
|
406
|
+
assert_nothing_raised { img.clut_channel(clut, Magick::RedChannel, Magick::BlueChannel) }
|
407
|
+
assert_raises(ArgumentError) { img.clut_channel(clut, 1, Magick::RedChannel) }
|
408
|
+
end
|
409
|
+
|
410
|
+
def test_color_fill_to_border
|
411
|
+
assert_raise(ArgumentError) { @img.color_fill_to_border(-1, 1, 'red') }
|
412
|
+
assert_raise(ArgumentError) { @img.color_fill_to_border(1, 100, 'red') }
|
413
|
+
assert_nothing_raised do
|
414
|
+
res = @img.color_fill_to_border(@img.columns/2, @img.rows/2, 'red')
|
415
|
+
assert_instance_of(Magick::Image, res)
|
597
416
|
end
|
417
|
+
pixel = Magick::Pixel.new(Magick::QuantumRange)
|
418
|
+
assert_nothing_raised { @img.color_fill_to_border(@img.columns/2, @img.rows/2, pixel) }
|
419
|
+
end
|
598
420
|
|
599
|
-
|
600
|
-
|
601
|
-
|
602
|
-
|
603
|
-
|
604
|
-
assert_nothing_raised { Magick::Image.combine(r) }
|
605
|
-
assert_nothing_raised { Magick::Image.combine(r, g) }
|
606
|
-
assert_nothing_raised { Magick::Image.combine(r, g, b) }
|
607
|
-
assert_nothing_raised { Magick::Image.combine(r, g, b, a) }
|
608
|
-
assert_nothing_raised { Magick::Image.combine(nil, g) }
|
609
|
-
assert_nothing_raised { Magick::Image.combine(r, nil, b) }
|
610
|
-
assert_nothing_raised { Magick::Image.combine(r, g, nil, a) }
|
611
|
-
assert_nothing_raised { Magick::Image.combine(r, g, b, nil) }
|
612
|
-
res = Magick::Image.combine(r, g, b)
|
421
|
+
def test_color_floodfill
|
422
|
+
assert_raise(ArgumentError) { @img.color_floodfill(-1, 1, 'red') }
|
423
|
+
assert_raise(ArgumentError) { @img.color_floodfill(1, 100, 'red') }
|
424
|
+
assert_nothing_raised do
|
425
|
+
res = @img.color_floodfill(@img.columns/2, @img.rows/2, 'red')
|
613
426
|
assert_instance_of(Magick::Image, res)
|
614
|
-
assert_raise(ArgumentError) { Magick::Image.combine }
|
615
|
-
assert_raise(ArgumentError) { Magick::Image.combine(nil) }
|
616
|
-
assert_raise(ArgumentError) { Magick::Image.combine(r, g, b, a, r) }
|
617
|
-
assert_raise(TypeError) { Magick::Image.combine(1, g, b, a) }
|
618
427
|
end
|
428
|
+
pixel = Magick::Pixel.new(Magick::QuantumRange)
|
429
|
+
assert_nothing_raised { @img.color_floodfill(@img.columns/2, @img.rows/2, pixel) }
|
430
|
+
end
|
619
431
|
|
620
|
-
|
621
|
-
|
622
|
-
|
623
|
-
|
624
|
-
assert_nothing_raised { img1.compare_channel(img2, Magick::MeanSquaredErrorMetric) }
|
625
|
-
assert_nothing_raised { img1.compare_channel(img2, Magick::PeakAbsoluteErrorMetric) }
|
626
|
-
assert_nothing_raised { img1.compare_channel(img2, Magick::PeakSignalToNoiseRatioMetric) }
|
627
|
-
assert_nothing_raised { img1.compare_channel(img2, Magick::RootMeanSquaredErrorMetric) }
|
628
|
-
assert_raise(TypeError) { img1.compare_channel(img2, 2) }
|
629
|
-
assert_raise(ArgumentError) { img1.compare_channel }
|
630
|
-
|
631
|
-
ilist = Magick::ImageList.new
|
632
|
-
ilist << img2
|
633
|
-
assert_nothing_raised { img1.compare_channel(ilist, Magick::MeanAbsoluteErrorMetric) }
|
634
|
-
|
635
|
-
assert_nothing_raised { img1.compare_channel(img2, Magick::MeanAbsoluteErrorMetric, Magick::RedChannel) }
|
636
|
-
assert_nothing_raised { img1.compare_channel(img2, Magick::MeanAbsoluteErrorMetric, Magick::RedChannel, Magick::BlueChannel) }
|
637
|
-
assert_raise(TypeError) { img1.compare_channel(img2, Magick::MeanAbsoluteErrorMetric, 2) }
|
638
|
-
assert_raise(TypeError) { img1.compare_channel(img2, Magick::MeanAbsoluteErrorMetric, Magick::RedChannel, 2) }
|
639
|
-
|
640
|
-
res = img1.compare_channel(img2, Magick::MeanAbsoluteErrorMetric)
|
641
|
-
assert_instance_of(Array, res)
|
642
|
-
assert_instance_of(Magick::Image, res[0])
|
643
|
-
assert_instance_of(Float, res[1])
|
644
|
-
|
645
|
-
img2.destroy!
|
646
|
-
assert_raise(Magick::DestroyedImageError) { img1.compare_channel(img2, Magick::MeanAbsoluteErrorMetric) }
|
432
|
+
def test_color_histogram
|
433
|
+
assert_nothing_raised do
|
434
|
+
res = @img.color_histogram
|
435
|
+
assert_instance_of(Hash, res)
|
647
436
|
end
|
437
|
+
end
|
648
438
|
|
649
|
-
|
650
|
-
|
651
|
-
|
652
|
-
|
653
|
-
assert_raise(ArgumentError) { img1.composite }
|
654
|
-
assert_raise(ArgumentError) { img1.composite(img2) }
|
655
|
-
assert_raise(ArgumentError) { img1.composite(img2, Magick::NorthWestGravity) }
|
656
|
-
assert_raise(ArgumentError) { img1.composite(2) }
|
657
|
-
assert_raise(ArgumentError) { img1.composite(img2, 2) }
|
658
|
-
|
659
|
-
composite_ops = [
|
660
|
-
Magick::UndefinedCompositeOp,
|
661
|
-
Magick::NoCompositeOp,
|
662
|
-
Magick::AddCompositeOp,
|
663
|
-
Magick::AtopCompositeOp,
|
664
|
-
Magick::BumpmapCompositeOp,
|
665
|
-
Magick::ClearCompositeOp,
|
666
|
-
Magick::ColorizeCompositeOp,
|
667
|
-
Magick::CopyBlueCompositeOp,
|
668
|
-
Magick::CopyCompositeOp,
|
669
|
-
Magick::CopyGreenCompositeOp,
|
670
|
-
Magick::CopyOpacityCompositeOp,
|
671
|
-
Magick::CopyRedCompositeOp,
|
672
|
-
Magick::CopyCyanCompositeOp,
|
673
|
-
Magick::CopyMagentaCompositeOp,
|
674
|
-
Magick::CopyYellowCompositeOp,
|
675
|
-
Magick::CopyBlackCompositeOp,
|
676
|
-
Magick::DarkenCompositeOp,
|
677
|
-
Magick::DifferenceCompositeOp,
|
678
|
-
Magick::DisplaceCompositeOp,
|
679
|
-
Magick::DissolveCompositeOp,
|
680
|
-
Magick::DstAtopCompositeOp,
|
681
|
-
Magick::DstCompositeOp,
|
682
|
-
Magick::DstInCompositeOp,
|
683
|
-
Magick::DstOutCompositeOp,
|
684
|
-
Magick::DstOverCompositeOp,
|
685
|
-
Magick::HueCompositeOp,
|
686
|
-
Magick::InCompositeOp,
|
687
|
-
Magick::LightenCompositeOp,
|
688
|
-
Magick::LuminizeCompositeOp,
|
689
|
-
Magick::MinusCompositeOp,
|
690
|
-
Magick::ModulateCompositeOp,
|
691
|
-
Magick::MultiplyCompositeOp,
|
692
|
-
Magick::OutCompositeOp,
|
693
|
-
Magick::OverCompositeOp,
|
694
|
-
Magick::OverlayCompositeOp,
|
695
|
-
Magick::PlusCompositeOp,
|
696
|
-
Magick::ReplaceCompositeOp,
|
697
|
-
Magick::SaturateCompositeOp,
|
698
|
-
Magick::ScreenCompositeOp,
|
699
|
-
Magick::SrcAtopCompositeOp,
|
700
|
-
Magick::SrcCompositeOp,
|
701
|
-
Magick::SrcInCompositeOp,
|
702
|
-
Magick::SrcOutCompositeOp,
|
703
|
-
Magick::SrcOverCompositeOp,
|
704
|
-
Magick::SubtractCompositeOp,
|
705
|
-
Magick::ThresholdCompositeOp,
|
706
|
-
Magick::XorCompositeOp,
|
707
|
-
Magick::BlendCompositeOp,
|
708
|
-
Magick::ColorBurnCompositeOp,
|
709
|
-
Magick::ColorDodgeCompositeOp,
|
710
|
-
Magick::ExclusionCompositeOp,
|
711
|
-
Magick::HardLightCompositeOp,
|
712
|
-
Magick::SoftLightCompositeOp]
|
713
|
-
gravity = [
|
714
|
-
Magick::NorthEastGravity,
|
715
|
-
Magick::EastGravity,
|
716
|
-
Magick::SouthWestGravity,
|
717
|
-
Magick::SouthGravity,
|
718
|
-
Magick::SouthEastGravity]
|
719
|
-
|
720
|
-
# 4 argument form
|
721
|
-
assert_nothing_raised { img1.composite(img2, 0, 0, Magick::OverCompositeOp) }
|
722
|
-
# there's way too many CompositeOperators to test them all, so just try few representative ops
|
723
|
-
composite_ops.each do |op|
|
724
|
-
assert_nothing_raised { img1.composite(img2, 0, 0, op) }
|
725
|
-
end
|
726
|
-
res = img1.composite(img2, 0, 0, Magick::OverCompositeOp)
|
727
|
-
assert_instance_of(Magick::Image, res)
|
728
|
-
assert_raise(TypeError) { img1.composite(img2, 0, 0, 2) }
|
729
|
-
|
730
|
-
# 3 argument form
|
731
|
-
composite_ops.each do |op|
|
732
|
-
gravity.each do |grav|
|
733
|
-
assert_nothing_raised { img1.composite(img2, grav, op) }
|
734
|
-
end
|
735
|
-
end
|
736
|
-
assert_raise(TypeError) { img1.composite(img2, 2, Magick::OverCompositeOp) }
|
737
|
-
|
738
|
-
# 5-argument form
|
739
|
-
composite_ops.each do |op|
|
740
|
-
gravity.each do |grav|
|
741
|
-
assert_nothing_raised { img1.composite(img2, grav, 0, 0, op) }
|
742
|
-
end
|
743
|
-
end
|
744
|
-
assert_raise(TypeError) { img1.composite(img2, 0, 0, 2, Magick::OverCompositeOp) }
|
745
|
-
|
746
|
-
# negative offsets raise an exception
|
747
|
-
# No longer true, negative offset are accepted as virtual pixels
|
748
|
-
#assert_raise(Magick::ImageMagickError) { img1.composite(img2, -10, -10, Magick::OverCompositeOp) }
|
749
|
-
|
750
|
-
img2.destroy!
|
751
|
-
assert_raise(Magick::DestroyedImageError) { img1.composite(img2, Magick::CenterGravity, Magick::OverCompositeOp) }
|
439
|
+
def test_colorize
|
440
|
+
assert_nothing_raised do
|
441
|
+
res = @img.colorize(0.25, 0.25, 0.25, 'red')
|
442
|
+
assert_instance_of(Magick::Image, res)
|
752
443
|
end
|
444
|
+
assert_nothing_raised { @img.colorize(0.25, 0.25, 0.25, 0.25, 'red') }
|
445
|
+
pixel = Magick::Pixel.new(Magick::QuantumRange)
|
446
|
+
assert_nothing_raised { @img.colorize(0.25, 0.25, 0.25, pixel) }
|
447
|
+
assert_nothing_raised { @img.colorize(0.25, 0.25, 0.25, 0.25, pixel) }
|
448
|
+
assert_raise(ArgumentError) { @img.colorize }
|
449
|
+
assert_raise(ArgumentError) { @img.colorize(0.25) }
|
450
|
+
assert_raise(ArgumentError) { @img.colorize(0.25, 0.25) }
|
451
|
+
assert_raise(ArgumentError) { @img.colorize(0.25, 0.25, 0.25) }
|
452
|
+
assert_raise(ArgumentError) { @img.colorize(0.25, 0.25, 0.25, 'X') }
|
453
|
+
# last argument must be a color name or pixel
|
454
|
+
assert_raise(TypeError) { @img.colorize(0.25, 0.25, 0.25, 0.25) }
|
455
|
+
assert_raise(ArgumentError) { @img.colorize(0.25, 0.25, 0.25, 0.25, 'X') }
|
456
|
+
assert_raise(TypeError) { @img.colorize(0.25, 0.25, 0.25, 0.25, [2]) }
|
457
|
+
end
|
458
|
+
|
459
|
+
def test_colormap
|
460
|
+
# IndexError b/c @img is DirectClass
|
461
|
+
assert_raise(IndexError) { @img.colormap(0) }
|
462
|
+
# Read PseudoClass image
|
463
|
+
pc_img = Magick::Image.read(IMAGES_DIR+'/Button_0.gif').first
|
464
|
+
assert_nothing_raised { pc_img.colormap(0) }
|
465
|
+
ncolors = pc_img.colors
|
466
|
+
assert_raise(IndexError) { pc_img.colormap(ncolors+1) }
|
467
|
+
assert_raise(IndexError) { pc_img.colormap(-1) }
|
468
|
+
assert_nothing_raised { pc_img.colormap(ncolors-1) }
|
469
|
+
res = pc_img.colormap(0)
|
470
|
+
assert_instance_of(String, res)
|
471
|
+
|
472
|
+
#test 'set' operation
|
473
|
+
assert_nothing_raised do
|
474
|
+
old_color = pc_img.colormap(0)
|
475
|
+
res = pc_img.colormap(0, 'red')
|
476
|
+
assert_equal(old_color, res)
|
477
|
+
res = pc_img.colormap(0)
|
478
|
+
assert_equal('red', res)
|
479
|
+
end
|
480
|
+
pixel = Magick::Pixel.new(Magick::QuantumRange)
|
481
|
+
assert_nothing_raised { pc_img.colormap(0, pixel) }
|
482
|
+
assert_raise(TypeError) { pc_img.colormap(0, [2]) }
|
483
|
+
pc_img.freeze
|
484
|
+
assert_raise(FreezeError) { pc_img.colormap(0, 'red') }
|
485
|
+
end
|
486
|
+
|
487
|
+
def test_color_point
|
488
|
+
assert_nothing_raised do
|
489
|
+
res = @img.color_point(0, 0, 'red')
|
490
|
+
assert_instance_of(Magick::Image, res)
|
491
|
+
assert_not_same(@img, res)
|
492
|
+
end
|
493
|
+
pixel = Magick::Pixel.new(Magick::QuantumRange)
|
494
|
+
assert_nothing_raised { @img.color_point(0, 0, pixel) }
|
495
|
+
end
|
496
|
+
|
497
|
+
def test_color_reset!
|
498
|
+
assert_nothing_raised do
|
499
|
+
res = @img.color_reset!('red')
|
500
|
+
assert_same(@img, res)
|
501
|
+
end
|
502
|
+
pixel = Magick::Pixel.new(Magick::QuantumRange)
|
503
|
+
assert_nothing_raised { @img.color_reset!(pixel) }
|
504
|
+
assert_raise(TypeError) { @img.color_reset!([2]) }
|
505
|
+
assert_raise(ArgumentError) { @img.color_reset!('x') }
|
506
|
+
@img.freeze
|
507
|
+
assert_raise(FreezeError) { @img.color_reset!('red') }
|
508
|
+
end
|
509
|
+
|
510
|
+
def test_combine
|
511
|
+
r = Magick::Image.new(20,20) { self.background_color = 'red' }
|
512
|
+
g = Magick::Image.new(20,20) { self.background_color = 'green' }
|
513
|
+
b = Magick::Image.new(20,20) { self.background_color = 'blue' }
|
514
|
+
a = Magick::Image.new(20,20) { self.background_color = 'transparent' }
|
515
|
+
assert_nothing_raised { Magick::Image.combine(r) }
|
516
|
+
assert_nothing_raised { Magick::Image.combine(r, g) }
|
517
|
+
assert_nothing_raised { Magick::Image.combine(r, g, b) }
|
518
|
+
assert_nothing_raised { Magick::Image.combine(r, g, b, a) }
|
519
|
+
assert_nothing_raised { Magick::Image.combine(nil, g) }
|
520
|
+
assert_nothing_raised { Magick::Image.combine(r, nil, b) }
|
521
|
+
assert_nothing_raised { Magick::Image.combine(r, g, nil, a) }
|
522
|
+
assert_nothing_raised { Magick::Image.combine(r, g, b, nil) }
|
523
|
+
res = Magick::Image.combine(r, g, b)
|
524
|
+
assert_instance_of(Magick::Image, res)
|
525
|
+
assert_raise(ArgumentError) { Magick::Image.combine }
|
526
|
+
assert_raise(ArgumentError) { Magick::Image.combine(nil) }
|
527
|
+
assert_raise(ArgumentError) { Magick::Image.combine(r, g, b, a, r) }
|
528
|
+
assert_raise(TypeError) { Magick::Image.combine(1, g, b, a) }
|
529
|
+
end
|
530
|
+
|
531
|
+
def test_compare_channel
|
532
|
+
img1 = Magick::Image.read(IMAGES_DIR+'/Button_0.gif').first
|
533
|
+
img2 = Magick::Image.read(IMAGES_DIR+'/Button_1.gif').first
|
534
|
+
assert_nothing_raised { img1.compare_channel(img2, Magick::MeanAbsoluteErrorMetric) }
|
535
|
+
assert_nothing_raised { img1.compare_channel(img2, Magick::MeanSquaredErrorMetric) }
|
536
|
+
assert_nothing_raised { img1.compare_channel(img2, Magick::PeakAbsoluteErrorMetric) }
|
537
|
+
assert_nothing_raised { img1.compare_channel(img2, Magick::PeakSignalToNoiseRatioMetric) }
|
538
|
+
assert_nothing_raised { img1.compare_channel(img2, Magick::RootMeanSquaredErrorMetric) }
|
539
|
+
assert_raise(TypeError) { img1.compare_channel(img2, 2) }
|
540
|
+
assert_raise(ArgumentError) { img1.compare_channel }
|
541
|
+
|
542
|
+
ilist = Magick::ImageList.new
|
543
|
+
ilist << img2
|
544
|
+
assert_nothing_raised { img1.compare_channel(ilist, Magick::MeanAbsoluteErrorMetric) }
|
545
|
+
|
546
|
+
assert_nothing_raised { img1.compare_channel(img2, Magick::MeanAbsoluteErrorMetric, Magick::RedChannel) }
|
547
|
+
assert_nothing_raised { img1.compare_channel(img2, Magick::MeanAbsoluteErrorMetric, Magick::RedChannel, Magick::BlueChannel) }
|
548
|
+
assert_raise(TypeError) { img1.compare_channel(img2, Magick::MeanAbsoluteErrorMetric, 2) }
|
549
|
+
assert_raise(TypeError) { img1.compare_channel(img2, Magick::MeanAbsoluteErrorMetric, Magick::RedChannel, 2) }
|
550
|
+
|
551
|
+
res = img1.compare_channel(img2, Magick::MeanAbsoluteErrorMetric)
|
552
|
+
assert_instance_of(Array, res)
|
553
|
+
assert_instance_of(Magick::Image, res[0])
|
554
|
+
assert_instance_of(Float, res[1])
|
555
|
+
|
556
|
+
img2.destroy!
|
557
|
+
assert_raise(Magick::DestroyedImageError) { img1.compare_channel(img2, Magick::MeanAbsoluteErrorMetric) }
|
558
|
+
end
|
753
559
|
end
|
754
560
|
|
755
561
|
if __FILE__ == $PROGRAM_NAME
|