rdp-rmagick 0.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (388) hide show
  1. data/ChangeLog +769 -0
  2. data/Doxyfile +1514 -0
  3. data/README-Mac-OSX.txt +1 -0
  4. data/README.md +231 -0
  5. data/build_tarball.rake +215 -0
  6. data/doc/comtasks.html +287 -0
  7. data/doc/constants.html +1581 -0
  8. data/doc/css/doc.css +299 -0
  9. data/doc/css/popup.css +34 -0
  10. data/doc/css/ref.css +67 -0
  11. data/doc/draw.html +3269 -0
  12. data/doc/ex/InitialCoords.rb +23 -0
  13. data/doc/ex/NewCoordSys.rb +32 -0
  14. data/doc/ex/OrigCoordSys.rb +18 -0
  15. data/doc/ex/PreserveAspectRatio.rb +205 -0
  16. data/doc/ex/RotateScale.rb +37 -0
  17. data/doc/ex/Skew.rb +38 -0
  18. data/doc/ex/Use01.rb +16 -0
  19. data/doc/ex/Use02.rb +21 -0
  20. data/doc/ex/Use03.rb +16 -0
  21. data/doc/ex/ViewBox.rb +33 -0
  22. data/doc/ex/adaptive_threshold.rb +10 -0
  23. data/doc/ex/add_noise.rb +17 -0
  24. data/doc/ex/affine.rb +48 -0
  25. data/doc/ex/affine_transform.rb +20 -0
  26. data/doc/ex/arc.rb +49 -0
  27. data/doc/ex/arcpath.rb +33 -0
  28. data/doc/ex/arcs01.rb +28 -0
  29. data/doc/ex/arcs02.rb +61 -0
  30. data/doc/ex/average.rb +15 -0
  31. data/doc/ex/axes.rb +64 -0
  32. data/doc/ex/baseline_shift01.rb +18 -0
  33. data/doc/ex/bilevel_channel.rb +9 -0
  34. data/doc/ex/blur_image.rb +12 -0
  35. data/doc/ex/border.rb +10 -0
  36. data/doc/ex/bounding_box.rb +44 -0
  37. data/doc/ex/cbezier1.rb +42 -0
  38. data/doc/ex/cbezier2.rb +42 -0
  39. data/doc/ex/cbezier3.rb +42 -0
  40. data/doc/ex/cbezier4.rb +43 -0
  41. data/doc/ex/cbezier5.rb +43 -0
  42. data/doc/ex/cbezier6.rb +53 -0
  43. data/doc/ex/channel.rb +26 -0
  44. data/doc/ex/charcoal.rb +12 -0
  45. data/doc/ex/chop.rb +29 -0
  46. data/doc/ex/circle.rb +33 -0
  47. data/doc/ex/circle01.rb +17 -0
  48. data/doc/ex/clip_path.rb +60 -0
  49. data/doc/ex/coalesce.rb +60 -0
  50. data/doc/ex/color_fill_to_border.rb +29 -0
  51. data/doc/ex/color_floodfill.rb +28 -0
  52. data/doc/ex/color_histogram.rb +48 -0
  53. data/doc/ex/color_reset.rb +11 -0
  54. data/doc/ex/colorize.rb +16 -0
  55. data/doc/ex/colors.rb +64 -0
  56. data/doc/ex/compose_mask.rb +23 -0
  57. data/doc/ex/composite.rb +135 -0
  58. data/doc/ex/composite_layers.rb +53 -0
  59. data/doc/ex/composite_tiled.rb +23 -0
  60. data/doc/ex/contrast.rb +36 -0
  61. data/doc/ex/crop.rb +31 -0
  62. data/doc/ex/crop_with_gravity.rb +46 -0
  63. data/doc/ex/cubic01.rb +45 -0
  64. data/doc/ex/cubic02.rb +94 -0
  65. data/doc/ex/cycle_colormap.rb +21 -0
  66. data/doc/ex/dissolve.rb +13 -0
  67. data/doc/ex/drawcomp.rb +42 -0
  68. data/doc/ex/drop_shadow.rb +60 -0
  69. data/doc/ex/edge.rb +11 -0
  70. data/doc/ex/ellipse.rb +45 -0
  71. data/doc/ex/ellipse01.rb +22 -0
  72. data/doc/ex/emboss.rb +11 -0
  73. data/doc/ex/enhance.rb +28 -0
  74. data/doc/ex/equalize.rb +11 -0
  75. data/doc/ex/evenodd.rb +43 -0
  76. data/doc/ex/fill_pattern.rb +26 -0
  77. data/doc/ex/flatten_images.rb +36 -0
  78. data/doc/ex/flip.rb +11 -0
  79. data/doc/ex/flop.rb +11 -0
  80. data/doc/ex/font_styles.rb +34 -0
  81. data/doc/ex/fonts.rb +20 -0
  82. data/doc/ex/frame.rb +12 -0
  83. data/doc/ex/gaussian_blur.rb +11 -0
  84. data/doc/ex/get_multiline_type_metrics.rb +42 -0
  85. data/doc/ex/get_pixels.rb +48 -0
  86. data/doc/ex/get_type_metrics.rb +146 -0
  87. data/doc/ex/gradientfill.rb +27 -0
  88. data/doc/ex/grav.rb +46 -0
  89. data/doc/ex/gravity.rb +79 -0
  90. data/doc/ex/group.rb +26 -0
  91. data/doc/ex/hatchfill.rb +27 -0
  92. data/doc/ex/image.rb +46 -0
  93. data/doc/ex/images/Apple.miff +0 -0
  94. data/doc/ex/images/Ballerina.jpg +0 -0
  95. data/doc/ex/images/Ballerina3.jpg +0 -0
  96. data/doc/ex/images/Button_0.gif +0 -0
  97. data/doc/ex/images/Button_1.gif +0 -0
  98. data/doc/ex/images/Button_2.gif +0 -0
  99. data/doc/ex/images/Button_3.gif +0 -0
  100. data/doc/ex/images/Button_4.gif +0 -0
  101. data/doc/ex/images/Button_5.gif +0 -0
  102. data/doc/ex/images/Button_6.gif +0 -0
  103. data/doc/ex/images/Button_7.gif +0 -0
  104. data/doc/ex/images/Button_8.gif +0 -0
  105. data/doc/ex/images/Button_9.gif +0 -0
  106. data/doc/ex/images/Button_A.gif +0 -0
  107. data/doc/ex/images/Button_B.gif +0 -0
  108. data/doc/ex/images/Button_C.gif +0 -0
  109. data/doc/ex/images/Button_D.gif +0 -0
  110. data/doc/ex/images/Button_E.gif +0 -0
  111. data/doc/ex/images/Button_F.gif +0 -0
  112. data/doc/ex/images/Button_G.gif +0 -0
  113. data/doc/ex/images/Button_H.gif +0 -0
  114. data/doc/ex/images/Button_I.gif +0 -0
  115. data/doc/ex/images/Button_J.gif +0 -0
  116. data/doc/ex/images/Button_K.gif +0 -0
  117. data/doc/ex/images/Button_L.gif +0 -0
  118. data/doc/ex/images/Button_M.gif +0 -0
  119. data/doc/ex/images/Button_N.gif +0 -0
  120. data/doc/ex/images/Button_O.gif +0 -0
  121. data/doc/ex/images/Button_P.gif +0 -0
  122. data/doc/ex/images/Button_Q.gif +0 -0
  123. data/doc/ex/images/Button_R.gif +0 -0
  124. data/doc/ex/images/Button_S.gif +0 -0
  125. data/doc/ex/images/Button_T.gif +0 -0
  126. data/doc/ex/images/Button_U.gif +0 -0
  127. data/doc/ex/images/Button_V.gif +0 -0
  128. data/doc/ex/images/Button_W.gif +0 -0
  129. data/doc/ex/images/Button_X.gif +0 -0
  130. data/doc/ex/images/Button_Y.gif +0 -0
  131. data/doc/ex/images/Button_Z.gif +0 -0
  132. data/doc/ex/images/Cheetah.jpg +0 -0
  133. data/doc/ex/images/Coffee.wmf +0 -0
  134. data/doc/ex/images/Flower_Hat.jpg +0 -0
  135. data/doc/ex/images/Gold_Statue.jpg +0 -0
  136. data/doc/ex/images/Hot_Air_Balloons.jpg +0 -0
  137. data/doc/ex/images/Hot_Air_Balloons_H.jpg +0 -0
  138. data/doc/ex/images/Leaf.miff +0 -0
  139. data/doc/ex/images/No.wmf +0 -0
  140. data/doc/ex/images/Polynesia.jpg +0 -0
  141. data/doc/ex/images/Red_Rocks.jpg +0 -0
  142. data/doc/ex/images/Rocks_On_Beach.miff +0 -0
  143. data/doc/ex/images/Shorts.jpg +0 -0
  144. data/doc/ex/images/Snake.wmf +0 -0
  145. data/doc/ex/images/Violin.jpg +0 -0
  146. data/doc/ex/images/Yellow_Rose.miff +0 -0
  147. data/doc/ex/images/big-duck.gif +0 -0
  148. data/doc/ex/images/duck.gif +0 -0
  149. data/doc/ex/images/duck0.gif +0 -0
  150. data/doc/ex/images/duck1.gif +0 -0
  151. data/doc/ex/images/duck10.gif +0 -0
  152. data/doc/ex/images/duck11.gif +0 -0
  153. data/doc/ex/images/duck12.gif +0 -0
  154. data/doc/ex/images/duck13.gif +0 -0
  155. data/doc/ex/images/duck14.gif +0 -0
  156. data/doc/ex/images/duck15.gif +0 -0
  157. data/doc/ex/images/duck2.gif +0 -0
  158. data/doc/ex/images/duck3.gif +0 -0
  159. data/doc/ex/images/duck4.gif +0 -0
  160. data/doc/ex/images/duck5.gif +0 -0
  161. data/doc/ex/images/duck6.gif +0 -0
  162. data/doc/ex/images/duck7.gif +0 -0
  163. data/doc/ex/images/duck8.gif +0 -0
  164. data/doc/ex/images/duck9.gif +0 -0
  165. data/doc/ex/images/graydient230x6.gif +0 -0
  166. data/doc/ex/images/logo400x83.gif +0 -0
  167. data/doc/ex/images/model.miff +0 -0
  168. data/doc/ex/images/notimplemented.gif +0 -0
  169. data/doc/ex/images/smile.miff +0 -0
  170. data/doc/ex/images/spin.gif +0 -0
  171. data/doc/ex/implode.rb +34 -0
  172. data/doc/ex/level.rb +11 -0
  173. data/doc/ex/level_colors.rb +11 -0
  174. data/doc/ex/line.rb +42 -0
  175. data/doc/ex/line01.rb +23 -0
  176. data/doc/ex/mask.rb +36 -0
  177. data/doc/ex/matte_fill_to_border.rb +40 -0
  178. data/doc/ex/matte_floodfill.rb +33 -0
  179. data/doc/ex/matte_replace.rb +40 -0
  180. data/doc/ex/median_filter.rb +28 -0
  181. data/doc/ex/modulate.rb +11 -0
  182. data/doc/ex/mono.rb +23 -0
  183. data/doc/ex/morph.rb +26 -0
  184. data/doc/ex/mosaic.rb +35 -0
  185. data/doc/ex/motion_blur.rb +11 -0
  186. data/doc/ex/negate.rb +11 -0
  187. data/doc/ex/negate_channel.rb +9 -0
  188. data/doc/ex/nested_rvg.rb +21 -0
  189. data/doc/ex/nonzero.rb +43 -0
  190. data/doc/ex/normalize.rb +11 -0
  191. data/doc/ex/oil_paint.rb +11 -0
  192. data/doc/ex/opacity.rb +37 -0
  193. data/doc/ex/ordered_dither.rb +11 -0
  194. data/doc/ex/path.rb +64 -0
  195. data/doc/ex/pattern1.rb +25 -0
  196. data/doc/ex/pattern2.rb +26 -0
  197. data/doc/ex/polaroid.rb +28 -0
  198. data/doc/ex/polygon.rb +24 -0
  199. data/doc/ex/polygon01.rb +23 -0
  200. data/doc/ex/polyline.rb +23 -0
  201. data/doc/ex/polyline01.rb +23 -0
  202. data/doc/ex/posterize.rb +8 -0
  203. data/doc/ex/preview.rb +9 -0
  204. data/doc/ex/qbezierpath.rb +52 -0
  205. data/doc/ex/quad01.rb +36 -0
  206. data/doc/ex/quantize-m.rb +25 -0
  207. data/doc/ex/radial_blur.rb +9 -0
  208. data/doc/ex/raise.rb +8 -0
  209. data/doc/ex/random_threshold_channel.rb +13 -0
  210. data/doc/ex/rect01.rb +15 -0
  211. data/doc/ex/rect02.rb +22 -0
  212. data/doc/ex/rectangle.rb +35 -0
  213. data/doc/ex/reduce_noise.rb +28 -0
  214. data/doc/ex/remap.rb +12 -0
  215. data/doc/ex/remap_images.rb +21 -0
  216. data/doc/ex/resize_to_fill.rb +10 -0
  217. data/doc/ex/resize_to_fit.rb +10 -0
  218. data/doc/ex/roll.rb +9 -0
  219. data/doc/ex/rotate.rb +45 -0
  220. data/doc/ex/rotate_f.rb +14 -0
  221. data/doc/ex/roundrect.rb +34 -0
  222. data/doc/ex/rubyname.rb +30 -0
  223. data/doc/ex/rvg_clippath.rb +14 -0
  224. data/doc/ex/rvg_linecap.rb +43 -0
  225. data/doc/ex/rvg_linejoin.rb +41 -0
  226. data/doc/ex/rvg_opacity.rb +19 -0
  227. data/doc/ex/rvg_pattern.rb +26 -0
  228. data/doc/ex/rvg_stroke_dasharray.rb +12 -0
  229. data/doc/ex/segment.rb +11 -0
  230. data/doc/ex/sepiatone.rb +8 -0
  231. data/doc/ex/shade.rb +11 -0
  232. data/doc/ex/shadow.rb +31 -0
  233. data/doc/ex/shave.rb +15 -0
  234. data/doc/ex/shear.rb +10 -0
  235. data/doc/ex/sketch.rb +18 -0
  236. data/doc/ex/skewx.rb +52 -0
  237. data/doc/ex/skewy.rb +47 -0
  238. data/doc/ex/smile.rb +125 -0
  239. data/doc/ex/solarize.rb +11 -0
  240. data/doc/ex/sparse_color.rb +55 -0
  241. data/doc/ex/splice.rb +9 -0
  242. data/doc/ex/spread.rb +11 -0
  243. data/doc/ex/stegano.rb +55 -0
  244. data/doc/ex/stroke_dasharray.rb +43 -0
  245. data/doc/ex/stroke_fill.rb +11 -0
  246. data/doc/ex/stroke_linecap.rb +44 -0
  247. data/doc/ex/stroke_linejoin.rb +48 -0
  248. data/doc/ex/stroke_width.rb +49 -0
  249. data/doc/ex/swirl.rb +17 -0
  250. data/doc/ex/text.rb +37 -0
  251. data/doc/ex/text01.rb +17 -0
  252. data/doc/ex/text_align.rb +36 -0
  253. data/doc/ex/text_antialias.rb +38 -0
  254. data/doc/ex/text_styles.rb +21 -0
  255. data/doc/ex/text_undercolor.rb +28 -0
  256. data/doc/ex/texture_fill_to_border.rb +34 -0
  257. data/doc/ex/texture_floodfill.rb +32 -0
  258. data/doc/ex/texturefill.rb +25 -0
  259. data/doc/ex/threshold.rb +13 -0
  260. data/doc/ex/to_blob.rb +14 -0
  261. data/doc/ex/translate.rb +39 -0
  262. data/doc/ex/transparent.rb +38 -0
  263. data/doc/ex/transpose.rb +9 -0
  264. data/doc/ex/transverse.rb +9 -0
  265. data/doc/ex/tref01.rb +25 -0
  266. data/doc/ex/triangle01.rb +16 -0
  267. data/doc/ex/trim.rb +24 -0
  268. data/doc/ex/tspan01.rb +18 -0
  269. data/doc/ex/tspan02.rb +19 -0
  270. data/doc/ex/tspan03.rb +21 -0
  271. data/doc/ex/unsharp_mask.rb +28 -0
  272. data/doc/ex/viewex.rb +35 -0
  273. data/doc/ex/vignette.rb +12 -0
  274. data/doc/ex/watermark.rb +28 -0
  275. data/doc/ex/wave.rb +9 -0
  276. data/doc/ex/wet_floor.rb +59 -0
  277. data/doc/ex/writing_mode01.rb +27 -0
  278. data/doc/ex/writing_mode02.rb +26 -0
  279. data/doc/ilist.html +2056 -0
  280. data/doc/image1.html +4680 -0
  281. data/doc/image2.html +3665 -0
  282. data/doc/image3.html +4522 -0
  283. data/doc/imageattrs.html +1638 -0
  284. data/doc/imusage.html +514 -0
  285. data/doc/index.html +416 -0
  286. data/doc/info.html +1499 -0
  287. data/doc/magick.html +565 -0
  288. data/doc/optequiv.html +2435 -0
  289. data/doc/rvg.html +975 -0
  290. data/doc/rvgclip.html +248 -0
  291. data/doc/rvggroup.html +305 -0
  292. data/doc/rvgimage.html +289 -0
  293. data/doc/rvgpattern.html +475 -0
  294. data/doc/rvgshape.html +406 -0
  295. data/doc/rvgstyle.html +270 -0
  296. data/doc/rvgtext.html +465 -0
  297. data/doc/rvgtspan.html +238 -0
  298. data/doc/rvgtut.html +530 -0
  299. data/doc/rvguse.html +145 -0
  300. data/doc/rvgxform.html +294 -0
  301. data/doc/scripts/doc.js +22 -0
  302. data/doc/scripts/stripeTables.js +23 -0
  303. data/doc/struct.html +1339 -0
  304. data/doc/usage.html +1621 -0
  305. data/examples/constitute.rb +7 -0
  306. data/examples/crop_with_gravity.rb +46 -0
  307. data/examples/demo.rb +324 -0
  308. data/examples/describe.rb +44 -0
  309. data/examples/find_similar_region.rb +34 -0
  310. data/examples/histogram.rb +325 -0
  311. data/examples/identify.rb +187 -0
  312. data/examples/image_opacity.rb +29 -0
  313. data/examples/import_export.rb +31 -0
  314. data/examples/pattern_fill.rb +38 -0
  315. data/examples/rotating_text.rb +45 -0
  316. data/examples/spinner.rb +50 -0
  317. data/examples/thumbnail.rb +65 -0
  318. data/examples/vignette.rb +79 -0
  319. data/ext/RMagick/Makefile +180 -0
  320. data/ext/RMagick/RMagick2.so +0 -0
  321. data/ext/RMagick/extconf.h +119 -0
  322. data/ext/RMagick/extconf.rb +406 -0
  323. data/ext/RMagick/mkmf.log +3022 -0
  324. data/ext/RMagick/rmagick.c +394 -0
  325. data/ext/RMagick/rmagick.h +1307 -0
  326. data/ext/RMagick/rmagick.o +0 -0
  327. data/ext/RMagick/rmdraw.c +1991 -0
  328. data/ext/RMagick/rmdraw.o +0 -0
  329. data/ext/RMagick/rmenum.c +1224 -0
  330. data/ext/RMagick/rmenum.o +0 -0
  331. data/ext/RMagick/rmfill.c +717 -0
  332. data/ext/RMagick/rmfill.o +0 -0
  333. data/ext/RMagick/rmilist.c +1217 -0
  334. data/ext/RMagick/rmilist.o +0 -0
  335. data/ext/RMagick/rmimage.c +15099 -0
  336. data/ext/RMagick/rmimage.o +0 -0
  337. data/ext/RMagick/rminfo.c +2567 -0
  338. data/ext/RMagick/rminfo.o +0 -0
  339. data/ext/RMagick/rmmain.c +1705 -0
  340. data/ext/RMagick/rmmain.o +0 -0
  341. data/ext/RMagick/rmmontage.c +511 -0
  342. data/ext/RMagick/rmmontage.o +0 -0
  343. data/ext/RMagick/rmpixel.c +1103 -0
  344. data/ext/RMagick/rmpixel.o +0 -0
  345. data/ext/RMagick/rmstruct.c +1047 -0
  346. data/ext/RMagick/rmstruct.o +0 -0
  347. data/ext/RMagick/rmutil.c +1730 -0
  348. data/ext/RMagick/rmutil.o +0 -0
  349. data/lib/RMagick.rb +1962 -0
  350. data/lib/rvg/clippath.rb +48 -0
  351. data/lib/rvg/container.rb +131 -0
  352. data/lib/rvg/deep_equal.rb +56 -0
  353. data/lib/rvg/describable.rb +53 -0
  354. data/lib/rvg/embellishable.rb +417 -0
  355. data/lib/rvg/misc.rb +740 -0
  356. data/lib/rvg/paint.rb +55 -0
  357. data/lib/rvg/pathdata.rb +131 -0
  358. data/lib/rvg/rvg.rb +283 -0
  359. data/lib/rvg/stretchable.rb +168 -0
  360. data/lib/rvg/stylable.rb +124 -0
  361. data/lib/rvg/text.rb +187 -0
  362. data/lib/rvg/to_c.rb +103 -0
  363. data/lib/rvg/transformable.rb +133 -0
  364. data/lib/rvg/units.rb +66 -0
  365. data/metaconfig +7 -0
  366. data/post-clean.rb +12 -0
  367. data/post-install.rb +50 -0
  368. data/post-setup.rb +254 -0
  369. data/rmagick.gemspec +20 -0
  370. data/setup.rb +1585 -0
  371. data/test/Draw.rb +121 -0
  372. data/test/Image1.rb +762 -0
  373. data/test/Image2.rb +1308 -0
  374. data/test/Image3.rb +1001 -0
  375. data/test/ImageList1.rb +808 -0
  376. data/test/ImageList2.rb +389 -0
  377. data/test/Image_attributes.rb +682 -0
  378. data/test/Import_Export.rb +116 -0
  379. data/test/Info.rb +349 -0
  380. data/test/Magick.rb +364 -0
  381. data/test/Pixel.rb +120 -0
  382. data/test/Preview.rb +62 -0
  383. data/test/all_basic.rb +39 -0
  384. data/test/cmyk.icm +0 -0
  385. data/test/srgb.icm +0 -0
  386. data/test/test.0 +0 -0
  387. data/uninstall.rb +74 -0
  388. metadata +455 -0
@@ -0,0 +1,1001 @@
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.1'
6
+ require 'fileutils'
7
+
8
+ ColorspaceTypes = [
9
+ Magick::RGBColorspace,
10
+ Magick::GRAYColorspace,
11
+ Magick::TransparentColorspace,
12
+ Magick::OHTAColorspace,
13
+ Magick::LABColorspace,
14
+ Magick::XYZColorspace,
15
+ Magick::YCbCrColorspace,
16
+ Magick::YCCColorspace,
17
+ Magick::YIQColorspace,
18
+ Magick::YPbPrColorspace,
19
+ Magick::YUVColorspace,
20
+ Magick::CMYKColorspace,
21
+ Magick::SRGBColorspace,
22
+ Magick::HSLColorspace,
23
+ Magick::HWBColorspace,
24
+ Magick::HSBColorspace,
25
+ Magick::LABColorspace,
26
+ Magick::Rec601LumaColorspace,
27
+ Magick::Rec601YCbCrColorspace,
28
+ Magick::Rec709LumaColorspace,
29
+ Magick::Rec709YCbCrColorspace,
30
+ Magick::LogColorspace
31
+ ]
32
+
33
+
34
+
35
+ class Image3_UT < Test::Unit::TestCase
36
+ FreezeError = RUBY_VERSION == '1.9.1' ? RuntimeError : TypeError
37
+
38
+ def setup
39
+ @img = Magick::Image.new(20, 20)
40
+ end
41
+
42
+ def test_profile!
43
+ assert_nothing_raised do
44
+ res = @img.profile!('*', nil)
45
+ assert_same(@img, res)
46
+ end
47
+ assert_nothing_raised { @img.profile!('icc', 'xxx') }
48
+ assert_nothing_raised { @img.profile!('iptc', 'xxx') }
49
+ assert_nothing_raised { @img.profile!('icc', nil) }
50
+ assert_nothing_raised { @img.profile!('iptc', nil) }
51
+
52
+ @img.freeze
53
+ assert_raise(FreezeError) { @img.profile!('icc', 'xxx') }
54
+ assert_raise(FreezeError) { @img.profile!('*', nil) }
55
+ end
56
+
57
+ def test_quantize
58
+ assert_nothing_raised do
59
+ res = @img.quantize
60
+ assert_instance_of(Magick::Image, res)
61
+ end
62
+
63
+ ColorspaceTypes.each do |cs|
64
+ assert_nothing_raised { @img.quantize(256, cs) }
65
+ end
66
+ assert_nothing_raised { @img.quantize(256, Magick::RGBColorspace, false) }
67
+ assert_nothing_raised { @img.quantize(256, Magick::RGBColorspace, true) }
68
+ assert_nothing_raised { @img.quantize(256, Magick::RGBColorspace, Magick::NoDitherMethod) }
69
+ assert_nothing_raised { @img.quantize(256, Magick::RGBColorspace, Magick::RiemersmaDitherMethod) }
70
+ assert_nothing_raised { @img.quantize(256, Magick::RGBColorspace, Magick::FloydSteinbergDitherMethod) }
71
+ assert_nothing_raised { @img.quantize(256, Magick::RGBColorspace, true, 2) }
72
+ assert_nothing_raised { @img.quantize(256, Magick::RGBColorspace, true, 2, true) }
73
+ assert_raise(TypeError) { @img.quantize('x') }
74
+ assert_raise(TypeError) { @img.quantize(16, 2) }
75
+ assert_raise(TypeError) { @img.quantize(16, Magick::RGBColorspace, false, 'x') }
76
+ end
77
+
78
+ def test_quantum_operator
79
+ quantum_ops = [
80
+ Magick::AddQuantumOperator,
81
+ Magick::AndQuantumOperator,
82
+ Magick::DivideQuantumOperator,
83
+ Magick::LShiftQuantumOperator,
84
+ Magick::MultiplyQuantumOperator,
85
+ Magick::OrQuantumOperator,
86
+ Magick::RShiftQuantumOperator,
87
+ Magick::SubtractQuantumOperator,
88
+ Magick::XorQuantumOperator ]
89
+
90
+ assert_nothing_raised do
91
+ res = @img.quantum_operator(Magick::AddQuantumOperator, 2)
92
+ assert_instance_of(Magick::Image, res)
93
+ end
94
+ quantum_ops.each do |op|
95
+ assert_nothing_raised { @img.quantum_operator(op, 2) }
96
+ end
97
+ assert_nothing_raised { @img.quantum_operator(Magick::AddQuantumOperator, 2, Magick::RedChannel) }
98
+ assert_raise(TypeError) { @img.quantum_operator(2, 2) }
99
+ assert_raise(TypeError) { @img.quantum_operator(Magick::AddQuantumOperator, 'x') }
100
+ assert_raise(TypeError) { @img.quantum_operator(Magick::AddQuantumOperator, 2, 2) }
101
+ assert_raise(ArgumentError) { @img.quantum_operator(Magick::AddQuantumOperator, 2, Magick::RedChannel, 2) }
102
+ end
103
+
104
+ def test_radial_blur
105
+ assert_nothing_raised do
106
+ res = @img.radial_blur(30)
107
+ assert_instance_of(Magick::Image, res)
108
+ end
109
+ end
110
+
111
+ def test_radial_blur_channel
112
+ res = nil
113
+ assert_nothing_raised { res = @img.radial_blur_channel(30) }
114
+ assert_not_nil(res)
115
+ assert_instance_of(Magick::Image, res)
116
+ assert_nothing_raised { res = @img.radial_blur_channel(30, Magick::RedChannel) }
117
+ assert_nothing_raised { res = @img.radial_blur_channel(30, Magick::RedChannel, Magick::BlueChannel) }
118
+
119
+ assert_raise(ArgumentError) { @img.radial_blur_channel }
120
+ assert_raise(TypeError) { @img.radial_blur_channel(30, 2) }
121
+ end
122
+
123
+ def test_raise
124
+ assert_nothing_raised do
125
+ res = @img.raise
126
+ assert_instance_of(Magick::Image, res)
127
+ end
128
+ assert_nothing_raised { @img.raise(4) }
129
+ assert_nothing_raised { @img.raise(4,4) }
130
+ assert_nothing_raised { @img.raise(4,4, false) }
131
+ assert_raise(TypeError) { @img.raise('x') }
132
+ assert_raise(TypeError) { @img.raise(2, 'x') }
133
+ assert_raise(ArgumentError) { @img.raise(4, 4, false, 2) }
134
+ end
135
+
136
+ def test_random_threshold_channel
137
+ assert_nothing_raised do
138
+ res = @img.random_threshold_channel('20%')
139
+ assert_instance_of(Magick::Image, res)
140
+ end
141
+ threshold = Magick::Geometry.new(20)
142
+ assert_nothing_raised { @img.random_threshold_channel(threshold) }
143
+ assert_nothing_raised { @img.random_threshold_channel(threshold, Magick::RedChannel) }
144
+ assert_nothing_raised { @img.random_threshold_channel(threshold, Magick::RedChannel, Magick::BlueChannel) }
145
+ assert_raise(ArgumentError) { @img.random_threshold_channel }
146
+ assert_raise(TypeError) { @img.random_threshold_channel('20%', 2) }
147
+ end
148
+
149
+ def test_reduce_noise
150
+ assert_nothing_raised do
151
+ res = @img.reduce_noise(0)
152
+ assert_instance_of(Magick::Image, res)
153
+ end
154
+ assert_nothing_raised { @img.reduce_noise(4) }
155
+ end
156
+
157
+ def test_remap
158
+ remap_image = Magick::Image.new(20,20) {self.background_color = "green"}
159
+ assert_nothing_raised { @img.remap(remap_image) }
160
+ assert_nothing_raised { @img.remap(remap_image, Magick::NoDitherMethod) }
161
+ assert_nothing_raised { @img.remap(remap_image, Magick::RiemersmaDitherMethod) }
162
+ assert_nothing_raised { @img.remap(remap_image, Magick::FloydSteinbergDitherMethod) }
163
+
164
+ assert_raise(ArgumentError) {@img.remap() }
165
+ assert_raise(ArgumentError) {@img.remap(remap_image, Magick::NoDitherMethod, 1) }
166
+ assert_raise(TypeError) {@img.remap(remap_image, 1) }
167
+ end
168
+
169
+ def test_resample
170
+ assert_nothing_raised { @img.resample }
171
+ assert_nothing_raised { @img.resample(100) }
172
+ assert_nothing_raised { @img.resample(100, 100) }
173
+
174
+ girl = Magick::Image.read(IMAGES_DIR+'/Flower_Hat.jpg').first
175
+ assert_equal(240.0, girl.x_resolution)
176
+ assert_equal(240.0, girl.y_resolution)
177
+ res = girl.resample(120, 120)
178
+ assert_equal(100, res.columns)
179
+ assert_equal(125, res.rows)
180
+ assert_equal(120.0, res.x_resolution)
181
+ assert_equal(120.0, res.y_resolution)
182
+
183
+ assert_raise(NoMethodError) { @img.resample('x') }
184
+ assert_raise(NoMethodError) { @img.resample(100, 'x') }
185
+ end
186
+
187
+ def test_resize
188
+ assert_nothing_raised do
189
+ res = @img.resize(2)
190
+ assert_instance_of(Magick::Image, res)
191
+ end
192
+ assert_nothing_raised { @img.resize(50,50) }
193
+ filters = [
194
+ Magick::PointFilter,
195
+ Magick::BoxFilter,
196
+ Magick::TriangleFilter,
197
+ Magick::HermiteFilter,
198
+ Magick::HanningFilter,
199
+ Magick::HammingFilter,
200
+ Magick::BlackmanFilter,
201
+ Magick::GaussianFilter,
202
+ Magick::QuadraticFilter,
203
+ Magick::CubicFilter,
204
+ Magick::CatromFilter,
205
+ Magick::MitchellFilter,
206
+ Magick::LanczosFilter,
207
+ Magick::BesselFilter,
208
+ Magick::SincFilter ]
209
+
210
+ filters.each do |filter|
211
+ assert_nothing_raised { @img.resize(50, 50, filter) }
212
+ end
213
+ assert_nothing_raised { @img.resize(50, 50, Magick::PointFilter, 2.0) }
214
+ assert_raise(TypeError) { @img.resize('x') }
215
+ assert_raise(TypeError) { @img.resize(50, 'x') }
216
+ assert_raise(TypeError) { @img.resize(50, 50, 2) }
217
+ assert_raise(TypeError) { @img.resize(50, 50, Magick::CubicFilter, 'x') }
218
+ assert_raise(ArgumentError) { @img.resize(50, 50, Magick::SincFilter, 2.0, 'x') }
219
+ assert_raise(ArgumentError) { @img.resize }
220
+ end
221
+
222
+ def test_resize!
223
+ assert_nothing_raised do
224
+ res = @img.resize!(2)
225
+ assert_same(@img, res)
226
+ end
227
+ @img.freeze
228
+ assert_raise(FreezeError) { @img.resize!(0.50) }
229
+ end
230
+
231
+ def test_resize_to_fill_0
232
+ changed = @img.resize_to_fill(@img.columns,@img.rows)
233
+ assert_equal(@img.columns, changed.columns)
234
+ assert_equal(@img.rows, changed.rows)
235
+ assert_not_same(changed, @img)
236
+ end
237
+
238
+ def test_resize_to_fill_1
239
+ @img = Magick::Image.new(200, 250)
240
+ @img.resize_to_fill!(100,100)
241
+ assert_equal(100, @img.columns)
242
+ assert_equal(100, @img.rows)
243
+ end
244
+
245
+ def test_resize_to_fill_2
246
+ @img = Magick::Image.new(200, 250)
247
+ changed = @img.resize_to_fill(300,100)
248
+ assert_equal(300, changed.columns)
249
+ assert_equal(100, changed.rows)
250
+ end
251
+
252
+ def test_resize_to_fill_3
253
+ @img = Magick::Image.new(200, 250)
254
+ changed = @img.resize_to_fill(100,300)
255
+ assert_equal(100, changed.columns)
256
+ assert_equal(300, changed.rows)
257
+ end
258
+
259
+ def test_resize_to_fill_4
260
+ @img = Magick::Image.new(200, 250)
261
+ changed = @img.resize_to_fill(300,350)
262
+ assert_equal(300, changed.columns)
263
+ assert_equal(350, changed.rows)
264
+ end
265
+
266
+ def test_resize_to_fill_5
267
+ changed = @img.resize_to_fill(20,400)
268
+ assert_equal(20, changed.columns)
269
+ assert_equal(400, changed.rows)
270
+ end
271
+ def test_resize_to_fill_6
272
+ changed = @img.resize_to_fill(3000,400)
273
+ assert_equal(3000, changed.columns)
274
+ assert_equal(400, changed.rows)
275
+ end
276
+
277
+ # Make sure the old name is still around
278
+ def test_resize_to_fill_7
279
+ assert_block {@img.respond_to? :crop_resized}
280
+ assert_block {@img.respond_to? :crop_resized!}
281
+ end
282
+
283
+ # 2nd argument defaults to the same value as the 1st argument
284
+ def test_resize_to_fill_8
285
+ changed = @img.resize_to_fill(100)
286
+ assert_equal(100, changed.columns)
287
+ assert_equal(100, changed.rows)
288
+ end
289
+
290
+ def test_resize_to_fit
291
+ img = Magick::Image.new(200, 250)
292
+ res = nil
293
+ assert_nothing_raised { res = img.resize_to_fit(50, 50) }
294
+ assert_not_nil(res)
295
+ assert_instance_of(Magick::Image, res)
296
+ assert_not_same(img, res)
297
+ assert_equal(40, res.columns)
298
+ assert_equal(50, res.rows)
299
+ end
300
+
301
+ def test_resize_to_fit2
302
+ img = Magick::Image.new(200, 300)
303
+ changed = img.resize_to_fit(100)
304
+ assert_instance_of(Magick::Image, changed)
305
+ assert_not_same(img, changed)
306
+ assert_equal(67, changed.columns)
307
+ assert_equal(100, changed.rows)
308
+ end
309
+
310
+ def test_resize_to_fit3
311
+ img = Magick::Image.new(200, 300)
312
+ keep = img
313
+ img.resize_to_fit!(100)
314
+ assert_instance_of(Magick::Image, img)
315
+ assert_same(img, keep)
316
+ assert_equal(67, img.columns)
317
+ assert_equal(100, img.rows)
318
+ end
319
+
320
+ def test_roll
321
+ assert_nothing_raised do
322
+ res = @img.roll(5, 5)
323
+ assert_instance_of(Magick::Image, res)
324
+ end
325
+ end
326
+
327
+ def test_rotate
328
+ assert_nothing_raised do
329
+ res = @img.rotate(45)
330
+ assert_instance_of(Magick::Image, res)
331
+ end
332
+ assert_nothing_raised { @img.rotate(-45) }
333
+
334
+ img = Magick::Image.new(100, 50)
335
+ assert_nothing_raised do
336
+ res = img.rotate(90, '>')
337
+ assert_instance_of(Magick::Image, res)
338
+ assert_equal(50, res.columns)
339
+ assert_equal(100, res.rows);
340
+ end
341
+ assert_nothing_raised do
342
+ res = img.rotate(90, '<')
343
+ assert_nil(res)
344
+ end
345
+ assert_raise(ArgumentError) { img.rotate(90, 't') }
346
+ assert_raise(TypeError) { img.rotate(90, []) }
347
+ end
348
+
349
+ def test_rotate!
350
+ assert_nothing_raised do
351
+ res = @img.rotate!(45)
352
+ assert_same(@img, res)
353
+ end
354
+ @img.freeze
355
+ assert_raise(FreezeError) { @img.rotate!(45) }
356
+ end
357
+
358
+ def test_sample
359
+ assert_nothing_raised do
360
+ res = @img.sample(10, 10)
361
+ assert_instance_of(Magick::Image, res)
362
+ end
363
+ assert_nothing_raised { @img.sample(2) }
364
+ assert_raise(ArgumentError) { @img.sample }
365
+ assert_raise(ArgumentError) { @img.sample(25, 25, 25) }
366
+ assert_raise(TypeError) { @img.sample('x') }
367
+ assert_raise(TypeError) { @img.sample(10, 'x') }
368
+ end
369
+
370
+ def test_sample!
371
+ assert_nothing_raised do
372
+ res = @img.sample!(2)
373
+ assert_same(@img, res)
374
+ end
375
+ @img.freeze
376
+ assert_raise(FreezeError) { @img.sample!(0.50) }
377
+ end
378
+
379
+ def test_scale
380
+ assert_nothing_raised do
381
+ res = @img.scale(10, 10)
382
+ assert_instance_of(Magick::Image, res)
383
+ end
384
+ assert_nothing_raised { @img.scale(2) }
385
+ assert_raise(ArgumentError) { @img.scale }
386
+ assert_raise(ArgumentError) { @img.scale(25, 25, 25) }
387
+ assert_raise(TypeError) { @img.scale('x') }
388
+ assert_raise(TypeError) { @img.scale(10, 'x') }
389
+ end
390
+
391
+ def test_scale!
392
+ assert_nothing_raised do
393
+ res = @img.scale!(2)
394
+ assert_same(@img, res)
395
+ end
396
+ @img.freeze
397
+ assert_raise(FreezeError) { @img.scale!(0.50) }
398
+ end
399
+
400
+ def test_segment
401
+ assert_nothing_raised do
402
+ res = @img.segment
403
+ assert_instance_of(Magick::Image, res)
404
+ end
405
+
406
+ # Don't test colorspaces that require PsuedoColor images
407
+ (ColorspaceTypes - [Magick::OHTAColorspace,
408
+ Magick::LABColorspace,
409
+ Magick::XYZColorspace,
410
+ Magick::YCbCrColorspace,
411
+ Magick::YCCColorspace,
412
+ Magick::YIQColorspace,
413
+ Magick::YPbPrColorspace,
414
+ Magick::YUVColorspace,
415
+ Magick::Rec601YCbCrColorspace,
416
+ Magick::Rec709YCbCrColorspace,
417
+ Magick::LogColorspace]).each do |cs|
418
+ assert_nothing_raised { @img.segment(cs) }
419
+ end
420
+
421
+ assert_nothing_raised { @img.segment(Magick::RGBColorspace, 2.0) }
422
+ assert_nothing_raised { @img.segment(Magick::RGBColorspace, 2.0, 2.0) }
423
+ assert_nothing_raised { @img.segment(Magick::RGBColorspace, 2.0, 2.0, false) }
424
+
425
+ assert_raise(ArgumentError) { @img.segment(Magick::RGBColorspace, 2.0, 2.0, false, 2) }
426
+ assert_raise(TypeError) { @img.segment(2) }
427
+ assert_raise(TypeError) { @img.segment(Magick::RGBColorspace, 'x') }
428
+ assert_raise(TypeError) { @img.segment(Magick::RGBColorspace, 2.0, 'x') }
429
+ end
430
+
431
+ def test_selective_blur_channel
432
+ res = nil
433
+ assert_nothing_raised { res = @img.selective_blur_channel(0, 1, '10%') }
434
+ assert_instance_of(Magick::Image, res)
435
+ assert_not_same(@img, res)
436
+ assert_equal([@img.columns, @img.rows], [res.columns, res.rows])
437
+
438
+ assert_nothing_raised { @img.selective_blur_channel(0, 1, 0.1) }
439
+ assert_nothing_raised { @img.selective_blur_channel(0, 1, '10%', Magick::RedChannel) }
440
+ assert_nothing_raised { @img.selective_blur_channel(0, 1, '10%', Magick::RedChannel, Magick::BlueChannel) }
441
+ assert_nothing_raised { @img.selective_blur_channel(0, 1, '10%', Magick::RedChannel, Magick::BlueChannel, Magick::GreenChannel) }
442
+ # not enough arguments
443
+ assert_raise(ArgumentError) { @img.selective_blur_channel(0, 1) }
444
+ end
445
+
446
+ def test_sepiatone
447
+ assert_nothing_raised do
448
+ res = @img.sepiatone
449
+ assert_instance_of(Magick::Image, res)
450
+ end
451
+ assert_nothing_raised { @img.sepiatone(Magick::QuantumRange*0.80) }
452
+ assert_raise(ArgumentError) { @img.sepiatone(Magick::QuantumRange, 2) }
453
+ assert_raise(TypeError) { @img.sepiatone('x') }
454
+ end
455
+
456
+ def test_set_channel_depth
457
+ channels = [
458
+ Magick::RedChannel,
459
+ Magick::GrayChannel,
460
+ Magick::CyanChannel,
461
+ Magick::GreenChannel,
462
+ Magick::MagentaChannel,
463
+ Magick::BlueChannel,
464
+ Magick::YellowChannel,
465
+ # Magick::AlphaChannel,
466
+ Magick::OpacityChannel,
467
+ Magick::MatteChannel,
468
+ Magick::BlackChannel,
469
+ Magick::IndexChannel,
470
+ Magick::AllChannels]
471
+
472
+ channels.each do |ch|
473
+ assert_nothing_raised {@img.set_channel_depth(ch, 8) }
474
+ end
475
+ end
476
+
477
+ def test_shade
478
+ assert_nothing_raised do
479
+ res = @img.shade
480
+ assert_instance_of(Magick::Image, res)
481
+ end
482
+ assert_nothing_raised { @img.shade(true) }
483
+ assert_nothing_raised { @img.shade(true, 30) }
484
+ assert_nothing_raised { @img.shade(true, 30, 30) }
485
+ assert_raise(ArgumentError) { @img.shade(true, 30, 30, 2) }
486
+ assert_raise(TypeError) { @img.shade(true, 'x') }
487
+ assert_raise(TypeError) { @img.shade(true, 30, 'x') }
488
+ end
489
+
490
+ def test_shadow
491
+ assert_nothing_raised do
492
+ res = @img.shadow
493
+ assert_instance_of(Magick::Image, res)
494
+ end
495
+ assert_nothing_raised { @img.shadow(5) }
496
+ assert_nothing_raised { @img.shadow(5, 5) }
497
+ assert_nothing_raised { @img.shadow(5, 5, 3.0) }
498
+ assert_nothing_raised { @img.shadow(5, 5, 3.0, 0.50) }
499
+ assert_nothing_raised { @img.shadow(5, 5, 3.0, '50%') }
500
+ assert_raise(ArgumentError) { @img.shadow(5, 5, 3.0, 0.50, 2) }
501
+ assert_raise(TypeError) { @img.shadow('x') }
502
+ assert_raise(TypeError) { @img.shadow(5, 'x') }
503
+ assert_raise(TypeError) { @img.shadow(5, 5, 'x') }
504
+ assert_raise(ArgumentError) { @img.shadow(5, 5, 3.0, 'x') }
505
+ end
506
+
507
+ def test_sharpen
508
+ assert_nothing_raised do
509
+ res = @img.sharpen
510
+ assert_instance_of(Magick::Image, res)
511
+ end
512
+ assert_nothing_raised { @img.sharpen(2.0) }
513
+ assert_nothing_raised { @img.sharpen(2.0, 1.0) }
514
+ assert_raise(ArgumentError) { @img.sharpen(2.0, 1.0, 2) }
515
+ assert_raise(TypeError) { @img.sharpen('x') }
516
+ assert_raise(TypeError) { @img.sharpen(2.0, 'x') }
517
+ end
518
+
519
+ def test_sharpen_channel
520
+ assert_nothing_raised do
521
+ res = @img.sharpen_channel
522
+ assert_instance_of(Magick::Image, res)
523
+ end
524
+ assert_nothing_raised { @img.sharpen_channel(2.0) }
525
+ assert_nothing_raised { @img.sharpen_channel(2.0, 1.0) }
526
+ assert_nothing_raised { @img.sharpen_channel(2.0, 1.0, Magick::RedChannel) }
527
+ assert_nothing_raised { @img.sharpen_channel(2.0, 1.0, Magick::RedChannel, Magick::BlueChannel) }
528
+ assert_raise(TypeError) { @img.sharpen_channel(2.0, 1.0, Magick::RedChannel, 2) }
529
+ assert_raise(TypeError) { @img.sharpen_channel('x') }
530
+ assert_raise(TypeError) { @img.sharpen_channel(2.0, 'x') }
531
+ end
532
+
533
+ def test_shave
534
+ assert_nothing_raised do
535
+ res = @img.shave(5,5)
536
+ assert_instance_of(Magick::Image, res)
537
+ end
538
+ assert_nothing_raised do
539
+ res = @img.shave!(5,5)
540
+ assert_same(@img, res)
541
+ end
542
+ @img.freeze
543
+ assert_raise(FreezeError) { @img.shave!(2,2) }
544
+ end
545
+
546
+ def test_shear
547
+ assert_nothing_raised do
548
+ res = @img.shear(30, 30)
549
+ assert_instance_of(Magick::Image, res)
550
+ end
551
+ end
552
+
553
+ def test_sigmoidal_contrast_channel
554
+ assert_nothing_raised do
555
+ res = @img.sigmoidal_contrast_channel
556
+ assert_instance_of(Magick::Image, res)
557
+ end
558
+ assert_nothing_raised { @img.sigmoidal_contrast_channel(3.0) }
559
+ assert_nothing_raised { @img.sigmoidal_contrast_channel(3.0, 50.0) }
560
+ assert_nothing_raised { @img.sigmoidal_contrast_channel(3.0, 50.0, true) }
561
+ assert_nothing_raised { @img.sigmoidal_contrast_channel(3.0, 50.0, true, Magick::RedChannel) }
562
+ assert_nothing_raised { @img.sigmoidal_contrast_channel(3.0, 50.0, true, Magick::RedChannel, Magick::BlueChannel) }
563
+ assert_raise(TypeError) { @img.sigmoidal_contrast_channel(3.0, 50.0, true, Magick::RedChannel, 2) }
564
+ assert_raise(TypeError) { @img.sigmoidal_contrast_channel('x') }
565
+ assert_raise(TypeError) { @img.sigmoidal_contrast_channel(3.0, 'x') }
566
+ end
567
+
568
+ def test_signature
569
+ assert_nothing_raised do
570
+ res = @img.signature
571
+ assert_instance_of(String, res)
572
+ end
573
+ end
574
+
575
+ def test_sketch
576
+ assert_nothing_raised { @img.sketch }
577
+ assert_nothing_raised { @img.sketch(0) }
578
+ assert_nothing_raised { @img.sketch(0, 1) }
579
+ assert_nothing_raised { @img.sketch(0, 1, 0) }
580
+ assert_raise(ArgumentError) { @img.sketch(0, 1, 0, 1) }
581
+ assert_raise(TypeError) { @img.sketch('x') }
582
+ assert_raise(TypeError) { @img.sketch(0, 'x') }
583
+ assert_raise(TypeError) { @img.sketch(0, 1, 'x') }
584
+ end
585
+
586
+ def test_solarize
587
+ assert_nothing_raised do
588
+ res = @img.solarize
589
+ assert_instance_of(Magick::Image, res)
590
+ end
591
+ assert_nothing_raised { @img.solarize(100) }
592
+ assert_raise(ArgumentError) { @img.solarize(100, 2) }
593
+ assert_raise(TypeError) { @img.solarize('x') }
594
+ end
595
+
596
+ def test_sparse_color
597
+ img = Magick::Image.new(100, 100)
598
+ args = [30, 10, 'red', 10, 80, 'blue', 70, 60, 'lime', 80, 20, 'yellow']
599
+ # assert good calls work
600
+ Magick::SparseColorMethod.values do |v|
601
+ next if v == Magick::UndefinedColorInterpolate
602
+ assert_nothing_raised { img.sparse_color(v, *args) }
603
+ end
604
+ args << Magick::RedChannel
605
+ assert_nothing_raised { img.sparse_color(Magick::VoronoiColorInterpolate, *args) }
606
+ args << Magick::GreenChannel
607
+ assert_nothing_raised { img.sparse_color(Magick::VoronoiColorInterpolate, *args) }
608
+ args << Magick::BlueChannel
609
+ assert_nothing_raised { img.sparse_color(Magick::VoronoiColorInterpolate, *args) }
610
+
611
+ # bad calls
612
+ args = [30, 10, 'red', 10, 80, 'blue', 70, 60, 'lime', 80, 20, 'yellow']
613
+ # invalid method
614
+ assert_raise(TypeError) { img.sparse_color(1, *args) }
615
+ # missing arguments
616
+ assert_raise(ArgumentError) { img.sparse_color(Magick::VoronoiColorInterpolate) }
617
+ args << 10 # too many arguments
618
+ assert_raise(ArgumentError) { img.sparse_color(Magick::VoronoiColorInterpolate, *args) }
619
+ args.shift
620
+ args.shift # too few
621
+ assert_raise(ArgumentError) { img.sparse_color(Magick::VoronoiColorInterpolate, *args) }
622
+ end
623
+
624
+ def test_splice
625
+ assert_nothing_raised do
626
+ res = @img.splice(0, 0, 2, 2)
627
+ assert_instance_of(Magick::Image, res)
628
+ end
629
+ assert_nothing_raised { @img.splice(0, 0, 2, 2, 'red') }
630
+ red = Magick::Pixel.new(Magick::QuantumRange)
631
+ assert_nothing_raised { @img.splice(0, 0, 2, 2, red) }
632
+ assert_raise(ArgumentError) { @img.splice(0,0, 2, 2, red, 'x') }
633
+ assert_raise(TypeError) { @img.splice([], 0, 2, 2, red) }
634
+ assert_raise(TypeError) { @img.splice(0, 'x', 2, 2, red) }
635
+ assert_raise(TypeError) { @img.splice(0, 0, 'x', 2, red) }
636
+ assert_raise(TypeError) { @img.splice(0, 0, 2, [], red) }
637
+ assert_raise(TypeError) { @img.splice(0, 0, 2, 2, /m/) }
638
+ end
639
+
640
+ def test_spread
641
+ assert_nothing_raised do
642
+ res = @img.spread
643
+ assert_instance_of(Magick::Image, res)
644
+ end
645
+ assert_nothing_raised { @img.spread(3.0) }
646
+ assert_raise(ArgumentError) { @img.spread(3.0, 2) }
647
+ assert_raise(TypeError) { @img.spread('x') }
648
+ end
649
+
650
+ def test_stegano
651
+ img = Magick::Image.new(100, 100) { self.background_color = 'black' }
652
+ watermark = Magick::Image.new(10, 10) { self.background_color = 'white' }
653
+ assert_nothing_raised do
654
+ res = @img.stegano(watermark, 0)
655
+ assert_instance_of(Magick::Image, res)
656
+ end
657
+
658
+ watermark.destroy!
659
+ assert_raise(Magick::DestroyedImageError) { @img.stegano(watermark, 0) }
660
+ end
661
+
662
+ def test_stereo
663
+ assert_nothing_raised do
664
+ res = @img.stereo(@img)
665
+ assert_instance_of(Magick::Image, res)
666
+ end
667
+
668
+ img = Magick::Image.new(20,20)
669
+ img.destroy!
670
+ assert_raise(Magick::DestroyedImageError) { @img.stereo(img) }
671
+ end
672
+
673
+ def test_store_pixels
674
+ pixels = @img.get_pixels(0, 0, @img.columns, 1)
675
+ assert_nothing_raised do
676
+ res = @img.store_pixels(0, 0, @img.columns, 1, pixels)
677
+ assert_same(@img, res)
678
+ end
679
+
680
+ pixels[0] = 'x'
681
+ assert_raise(TypeError) { @img.store_pixels(0, 0, @img.columns, 1, pixels) }
682
+ assert_raise(RangeError) { @img.store_pixels(-1, 0, @img.columns, 1, pixels) }
683
+ assert_raise(RangeError) { @img.store_pixels(0, -1, @img.columns, 1, pixels) }
684
+ assert_raise(RangeError) { @img.store_pixels(0, 0, 1+@img.columns, 1, pixels) }
685
+ assert_raise(RangeError) { @img.store_pixels(-1, 0, 1, 1+@img.rows, pixels) }
686
+ assert_raise(IndexError) { @img.store_pixels(0, 0, @img.columns, 1, ['x']) }
687
+ end
688
+
689
+ def test_strip!
690
+ assert_nothing_raised do
691
+ res = @img.strip!
692
+ assert_same(@img, res)
693
+ end
694
+ end
695
+
696
+ def test_swirl
697
+ assert_nothing_raised do
698
+ res = @img.swirl(30)
699
+ assert_instance_of(Magick::Image, res)
700
+ end
701
+ end
702
+
703
+ def test_sync_profiles
704
+ assert_nothing_raised { assert(@img.sync_profiles) }
705
+ end
706
+
707
+ def test_texture_fill_to_border
708
+ texture = Magick::Image.read('granite:').first
709
+ assert_nothing_raised do
710
+ res = @img.texture_fill_to_border(@img.columns/2, @img.rows/2, texture)
711
+ assert_instance_of(Magick::Image, res)
712
+ end
713
+ assert_raise(NoMethodError) { @img.texture_fill_to_border(@img.columns/2, @img.rows/2, 'x') }
714
+ end
715
+
716
+ def test_texture_floodfill
717
+ texture = Magick::Image.read('granite:').first
718
+ assert_nothing_raised do
719
+ res = @img.texture_floodfill(@img.columns/2, @img.rows/2, texture)
720
+ assert_instance_of(Magick::Image, res)
721
+ end
722
+ assert_raise(NoMethodError) { @img.texture_floodfill(@img.columns/2, @img.rows/2, 'x') }
723
+ texture.destroy!
724
+ assert_raise(Magick::DestroyedImageError) { @img.texture_floodfill(@img.columns/2, @img.rows/2, texture) }
725
+ end
726
+
727
+ def test_threshold
728
+ assert_nothing_raised do
729
+ res = @img.threshold(100)
730
+ assert_instance_of(Magick::Image, res)
731
+ end
732
+ end
733
+
734
+ def test_thumbnail
735
+ assert_nothing_raised do
736
+ res = @img.thumbnail(10, 10)
737
+ assert_instance_of(Magick::Image, res)
738
+ end
739
+ assert_nothing_raised { @img.thumbnail(2) }
740
+ assert_raise(ArgumentError) { @img.thumbnail }
741
+ assert_raise(ArgumentError) { @img.thumbnail(25, 25, 25) }
742
+ assert_raise(TypeError) { @img.thumbnail('x') }
743
+ assert_raise(TypeError) { @img.thumbnail(10, 'x') }
744
+ end
745
+
746
+ def test_thumbnail!
747
+ assert_nothing_raised do
748
+ res = @img.thumbnail!(2)
749
+ assert_same(@img, res)
750
+ end
751
+ @img.freeze
752
+ assert_raise(FreezeError) { @img.thumbnail!(0.50) }
753
+ end
754
+
755
+ def test_to_blob
756
+ res = nil
757
+ assert_nothing_raised { res = @img.to_blob { self.format = 'miff' } }
758
+ assert_instance_of(String, res)
759
+ restored = Magick::Image.from_blob(res)
760
+ assert_equal(@img, restored[0])
761
+ end
762
+
763
+ def test_to_color
764
+ red = Magick::Pixel.new(Magick::QuantumRange)
765
+ assert_nothing_raised do
766
+ res = @img.to_color(red)
767
+ assert_equal('red', res)
768
+ end
769
+ end
770
+
771
+ def test_transparent
772
+ assert_nothing_raised do
773
+ res = @img.transparent('white')
774
+ assert_instance_of(Magick::Image, res)
775
+ end
776
+ pixel = Magick::Pixel.new
777
+ assert_nothing_raised { @img.transparent(pixel) }
778
+ assert_nothing_raised { @img.transparent('white', Magick::TransparentOpacity) }
779
+ assert_raise(ArgumentError) { @img.transparent('white', Magick::TransparentOpacity, 2) }
780
+ assert_nothing_raised { @img.transparent('white', Magick::QuantumRange/2) }
781
+ assert_raise(TypeError) { @img.transparent(2) }
782
+ end
783
+
784
+ def test_transpose
785
+ assert_nothing_raised do
786
+ res = @img.transpose
787
+ assert_instance_of(Magick::Image, res)
788
+ assert_not_same(@img, res)
789
+ end
790
+ assert_nothing_raised do
791
+ res = @img.transpose!
792
+ assert_instance_of(Magick::Image, res)
793
+ assert_same(@img, res)
794
+ end
795
+ end
796
+
797
+ def test_transverse
798
+ assert_nothing_raised do
799
+ res = @img.transverse
800
+ assert_instance_of(Magick::Image, res)
801
+ assert_not_same(@img, res)
802
+ end
803
+ assert_nothing_raised do
804
+ res = @img.transverse!
805
+ assert_instance_of(Magick::Image, res)
806
+ assert_same(@img, res)
807
+ end
808
+ end
809
+
810
+ def test_trim
811
+ # Can't use the default image because it's a solid color
812
+ hat = Magick::Image.read(IMAGES_DIR+'/Flower_Hat.jpg').first
813
+ assert_nothing_raised do
814
+ res = hat.trim
815
+ assert_instance_of(Magick::Image, res)
816
+ end
817
+ assert_nothing_raised do
818
+ res = hat.trim!
819
+ assert_same(hat, res)
820
+ end
821
+ end
822
+
823
+ def test_unique_colors
824
+ assert_nothing_raised do
825
+ res = @img.unique_colors
826
+ assert_instance_of(Magick::Image, res)
827
+ assert_equal(1, res.columns)
828
+ assert_equal(1, res.rows)
829
+ end
830
+ end
831
+
832
+ def test_unsharp_mask
833
+ assert_nothing_raised do
834
+ res = @img.unsharp_mask
835
+ assert_instance_of(Magick::Image, res)
836
+ end
837
+
838
+ assert_nothing_raised { @img.unsharp_mask(2.0) }
839
+ assert_nothing_raised { @img.unsharp_mask(2.0, 1.0) }
840
+ assert_nothing_raised { @img.unsharp_mask(2.0, 1.0, 0.50) }
841
+ assert_nothing_raised { @img.unsharp_mask(2.0, 1.0, 0.50, 0.10) }
842
+ assert_raise(ArgumentError) { @img.unsharp_mask(2.0, 1.0, 0.50, 0.10, 2) }
843
+ assert_raise(TypeError) { @img.unsharp_mask('x') }
844
+ assert_raise(TypeError) { @img.unsharp_mask(2.0, 'x') }
845
+ assert_raise(TypeError) { @img.unsharp_mask(2.0, 1.0, 'x') }
846
+ assert_raise(TypeError) { @img.unsharp_mask(2.0, 1.0, 0.50, 'x') }
847
+ end
848
+
849
+ def test_unsharp_mask_channel
850
+ assert_nothing_raised do
851
+ res = @img.unsharp_mask_channel
852
+ assert_instance_of(Magick::Image, res)
853
+ end
854
+
855
+ assert_nothing_raised { @img.unsharp_mask_channel(2.0) }
856
+ assert_nothing_raised { @img.unsharp_mask_channel(2.0, 1.0) }
857
+ assert_nothing_raised { @img.unsharp_mask_channel(2.0, 1.0, 0.50) }
858
+ assert_nothing_raised { @img.unsharp_mask_channel(2.0, 1.0, 0.50, 0.10) }
859
+ assert_nothing_raised { @img.unsharp_mask_channel(2.0, 1.0, 0.50, 0.10, Magick::RedChannel) }
860
+ assert_nothing_raised { @img.unsharp_mask_channel(2.0, 1.0, 0.50, 0.10, Magick::RedChannel, Magick::BlueChannel) }
861
+ assert_raise(TypeError) { @img.unsharp_mask_channel(2.0, 1.0, 0.50, 0.10, Magick::RedChannel, 2) }
862
+ assert_raise(TypeError) { @img.unsharp_mask_channel(2.0, 1.0, 0.50, 0.10, 2) }
863
+ assert_raise(TypeError) { @img.unsharp_mask_channel('x') }
864
+ assert_raise(TypeError) { @img.unsharp_mask_channel(2.0, 'x') }
865
+ assert_raise(TypeError) { @img.unsharp_mask_channel(2.0, 1.0, 'x') }
866
+ assert_raise(TypeError) { @img.unsharp_mask_channel(2.0, 1.0, 0.50, 'x') }
867
+ end
868
+
869
+ def test_view
870
+ assert_nothing_raised do
871
+ res = @img.view(0, 0, 5, 5)
872
+ assert_instance_of(Magick::Image::View, res)
873
+ end
874
+ assert_nothing_raised do
875
+ @img.view(0, 0, 5, 5) { |v| assert_instance_of(Magick::Image::View, v) }
876
+ end
877
+ assert_raise(RangeError) { @img.view(-1, 0, 5, 5) }
878
+ assert_raise(RangeError) { @img.view(0, -1, 5, 5) }
879
+ assert_raise(RangeError) { @img.view(1, 0, @img.columns, 5) }
880
+ assert_raise(RangeError) { @img.view(0, 1, 5, @img.rows) }
881
+ assert_raise(ArgumentError) { @img.view(0, 0, 0, 1) }
882
+ assert_raise(ArgumentError) { @img.view(0, 0, 1, 0) }
883
+ end
884
+
885
+ def test_vignette
886
+ assert_nothing_raised do
887
+ res = @img.vignette
888
+ assert_instance_of(Magick::Image, res)
889
+ assert_not_same(res, @img)
890
+ end
891
+ assert_nothing_raised { @img.vignette(0) }
892
+ assert_nothing_raised { @img.vignette(0, 0) }
893
+ assert_nothing_raised { @img.vignette(0, 0, 0) }
894
+ assert_nothing_raised { @img.vignette(0, 0, 0, 1) }
895
+ # too many arguments
896
+ assert_raise(ArgumentError) { @img.vignette(0, 0, 0, 1, 1) }
897
+ end
898
+
899
+ def test_watermark
900
+ mark = Magick::Image.new(5,5)
901
+ mark_list = Magick::ImageList.new
902
+ mark_list << mark.copy
903
+ assert_nothing_raised { @img.watermark(mark) }
904
+ assert_nothing_raised { @img.watermark(mark_list) }
905
+ assert_nothing_raised { @img.watermark(mark, 0.50) }
906
+ assert_nothing_raised { @img.watermark(mark, '50%') }
907
+ assert_nothing_raised { @img.watermark(mark, 0.50, 0.50) }
908
+ assert_nothing_raised { @img.watermark(mark, 0.50, '50%') }
909
+ assert_nothing_raised { @img.watermark(mark, 0.50, 0.50, 10) }
910
+ assert_nothing_raised { @img.watermark(mark, 0.50, 0.50, 10, 10) }
911
+ assert_nothing_raised { @img.watermark(mark, 0.50, 0.50, Magick::NorthEastGravity) }
912
+ assert_nothing_raised { @img.watermark(mark, 0.50, 0.50, Magick::NorthEastGravity, 10) }
913
+ assert_nothing_raised { @img.watermark(mark, 0.50, 0.50, Magick::NorthEastGravity, 10, 10) }
914
+
915
+ assert_raise(ArgumentError) { @img.watermark(mark, 'x') }
916
+ assert_raise(ArgumentError) { @img.watermark(mark, 0.50, 'x') }
917
+ assert_raise(TypeError) { @img.watermark(mark, 0.50, 0.50, 'x') }
918
+ assert_raise(TypeError) { @img.watermark(mark, 0.50, 0.50, Magick::NorthEastGravity, 'x') }
919
+ assert_raise(TypeError) { @img.watermark(mark, 0.50, 0.50, Magick::NorthEastGravity, 10, 'x') }
920
+
921
+ mark.destroy!
922
+ assert_raise(Magick::DestroyedImageError) { @img.watermark(mark) }
923
+ end
924
+
925
+ def test_wave
926
+ assert_nothing_raised do
927
+ res = @img.wave
928
+ assert_instance_of(Magick::Image, res)
929
+ end
930
+ assert_nothing_raised { @img.wave(25) }
931
+ assert_nothing_raised { @img.wave(25, 200) }
932
+ assert_raise(ArgumentError) { @img.wave(25, 200, 2) }
933
+ assert_raise(TypeError) { @img.wave('x') }
934
+ assert_raise(TypeError) { @img.wave(25, 'x') }
935
+ end
936
+
937
+ def test_white_threshold
938
+ assert_raise(ArgumentError) { @img.white_threshold }
939
+ assert_nothing_raised { @img.white_threshold(50) }
940
+ assert_nothing_raised { @img.white_threshold(50, 50) }
941
+ assert_nothing_raised { @img.white_threshold(50, 50, 50) }
942
+ assert_nothing_raised { @img.white_threshold(50, 50, 50, 50) }
943
+ assert_raise(ArgumentError) { @img.white_threshold(50, 50, 50, 50, 50) }
944
+ res = @img.white_threshold(50)
945
+ assert_instance_of(Magick::Image, res)
946
+ end
947
+
948
+ # test write with #format= attribute
949
+ def test_write
950
+
951
+ @img.write('temp.gif')
952
+ img = Magick::Image.read('temp.gif')
953
+ assert_equal("GIF", img.first.format)
954
+ FileUtils.rm('temp.gif')
955
+
956
+ @img.write("jpg:temp.foo")
957
+ img = Magick::Image.read('temp.foo')
958
+ assert_equal("JPEG", img.first.format)
959
+ FileUtils.rm('temp.foo')
960
+
961
+ @img.write("temp.0") { self.format = "JPEG" }
962
+ img = Magick::Image.read('temp.0')
963
+ assert_equal("JPEG", img.first.format)
964
+
965
+ # JPEG has two names.
966
+ @img.write("jpeg:temp.0") { self.format = "JPEG" }
967
+ img = Magick::Image.read('temp.0')
968
+ assert_equal("JPEG", img.first.format)
969
+
970
+ @img.write("jpg:temp.0") { self.format = "JPG" }
971
+ img = Magick::Image.read('temp.0')
972
+ assert_equal("JPEG", img.first.format)
973
+
974
+ @img.write("jpg:temp.0") { self.format = "JPEG" }
975
+ img = Magick::Image.read('temp.0')
976
+ assert_equal("JPEG", img.first.format)
977
+
978
+ @img.write("jpeg:temp.0") { self.format = "JPG" }
979
+ img = Magick::Image.read('temp.0')
980
+ assert_equal("JPEG", img.first.format)
981
+
982
+ assert_raise(RuntimeError) do
983
+ @img.write("gif:temp.0") { self.format = "JPEG" }
984
+ end
985
+
986
+ f = File.new("test.0", "w")
987
+ @img.write(f) { self.format = "JPEG" }
988
+ f.close
989
+ img = Magick::Image.read('test.0')
990
+ assert_equal("JPEG", img.first.format)
991
+ FileUtils.rm('test.0')
992
+ end
993
+
994
+
995
+ end
996
+
997
+ if __FILE__ == $0
998
+ IMAGES_DIR = '../doc/ex/images'
999
+ FILES = Dir[IMAGES_DIR+'/Button_*.gif']
1000
+ Test::Unit::UI::Console::TestRunner.run(Image3_UT) if RUBY_VERSION != '1.9.1'
1001
+ end