rmagick 3.2.0 → 4.3.0

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