rmagick 2.13.2 → 2.13.3.rc1

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.

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