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
@@ -1,312 +0,0 @@
1
- # This routine needs the color_histogram method
2
- # from either ImageMagick 6.0.0 or GraphicsMagick 1.1
3
- # Specify an image filename as an argument.
4
-
5
- require 'rmagick'
6
-
7
- class PixelColumn < Array
8
- def initialize(size)
9
- super
10
- fill { Magick::Pixel.new }
11
- end
12
-
13
- def reset(bg)
14
- each { |pixel| pixel.reset(bg) }
15
- end
16
- end
17
-
18
- module Magick
19
- class Pixel
20
- def reset(bg)
21
- self.red = bg.red
22
- self.green = bg.green
23
- self.blue = bg.blue
24
- self.opacity = bg.opacity
25
- end
26
- end
27
-
28
- class Image
29
- private
30
-
31
- HISTOGRAM_COLS = 256
32
- HISTOGRAM_ROWS = 200
33
- MAX_QUANTUM = 255
34
- AIR_FACTOR = 1.025
35
-
36
- # The alpha frequencies are shown as white dots.
37
- def alpha_hist(freqs, scale, fg, bg)
38
- histogram = Image.new(HISTOGRAM_COLS, HISTOGRAM_ROWS) do
39
- self.background_color = bg
40
- self.border_color = fg
41
- end
42
-
43
- gc = Draw.new
44
- gc.affine(1, 0, 0, -scale, 0, HISTOGRAM_ROWS)
45
- gc.fill('white')
46
-
47
- HISTOGRAM_COLS.times do |x|
48
- gc.point(x, freqs[x])
49
- end
50
-
51
- gc.draw(histogram)
52
- histogram['Label'] = 'Alpha'
53
-
54
- histogram
55
- end
56
-
57
- def channel_histograms(red, green, blue, int, scale, fg, bg)
58
- rgb_histogram = Image.new(HISTOGRAM_COLS, HISTOGRAM_ROWS) do
59
- self.background_color = bg
60
- self.border_color = fg
61
- end
62
- rgb_histogram['Label'] = 'RGB'
63
- red_histogram = rgb_histogram.copy
64
- red_histogram['Label'] = 'Red'
65
- green_histogram = rgb_histogram.copy
66
- green_histogram['Label'] = 'Green'
67
- blue_histogram = rgb_histogram.copy
68
- blue_histogram['Label'] = 'Blue'
69
- int_histogram = rgb_histogram.copy
70
- int_histogram['Label'] = 'Intensity'
71
- int_histogram.alpha(Magick::ActivateAlphaChannel)
72
-
73
- rgb_column = PixelColumn.new(HISTOGRAM_ROWS)
74
- red_column = PixelColumn.new(HISTOGRAM_ROWS)
75
- green_column = PixelColumn.new(HISTOGRAM_ROWS)
76
- blue_column = PixelColumn.new(HISTOGRAM_ROWS)
77
- int_column = PixelColumn.new(HISTOGRAM_ROWS)
78
-
79
- HISTOGRAM_COLS.times do |x|
80
- HISTOGRAM_ROWS.times do |y|
81
- yf = Float(y)
82
- if yf >= HISTOGRAM_ROWS - (red[x] * scale)
83
- red_column[y].red = QuantumRange
84
- red_column[y].green = 0
85
- red_column[y].blue = 0
86
- rgb_column[y].red = QuantumRange
87
- end
88
- if yf >= HISTOGRAM_ROWS - (green[x] * scale)
89
- green_column[y].green = QuantumRange
90
- green_column[y].red = 0
91
- green_column[y].blue = 0
92
- rgb_column[y].green = QuantumRange
93
- end
94
- if yf >= HISTOGRAM_ROWS - (blue[x] * scale)
95
- blue_column[y].blue = QuantumRange
96
- blue_column[y].red = 0
97
- blue_column[y].green = 0
98
- rgb_column[y].blue = QuantumRange
99
- end
100
- int_column[y].opacity = TransparentOpacity if yf >= HISTOGRAM_ROWS - (int[x] * scale)
101
- end
102
-
103
- rgb_histogram.store_pixels(x, 0, 1, HISTOGRAM_ROWS, rgb_column)
104
- red_histogram.store_pixels(x, 0, 1, HISTOGRAM_ROWS, red_column)
105
- green_histogram.store_pixels(x, 0, 1, HISTOGRAM_ROWS, green_column)
106
- blue_histogram.store_pixels(x, 0, 1, HISTOGRAM_ROWS, blue_column)
107
- int_histogram.store_pixels(x, 0, 1, HISTOGRAM_ROWS, int_column)
108
- rgb_column.reset(bg)
109
- red_column.reset(bg)
110
- green_column.reset(bg)
111
- blue_column.reset(bg)
112
- int_column.reset(bg)
113
- end
114
-
115
- [red_histogram, green_histogram, blue_histogram, rgb_histogram, int_histogram]
116
- end
117
-
118
- # Make the color histogram. Quantize the image to 256 colors if necessary.
119
- def color_hist(fg, bg)
120
- img = number_colors > 256 ? quantize(256) : self
121
-
122
- begin
123
- hist = img.color_histogram
124
- rescue NotImplementedError
125
- warn 'The color_histogram method is not supported by this version '\
126
- 'of ImageMagick/GraphicsMagick'
127
- else
128
- pixels = hist.keys.sort_by { |pixel| hist[pixel] }
129
- scale = HISTOGRAM_ROWS / (hist.values.max * AIR_FACTOR)
130
-
131
- histogram = Image.new(HISTOGRAM_COLS, HISTOGRAM_ROWS) do
132
- self.background_color = bg
133
- self.border_color = fg
134
- end
135
-
136
- x = 0
137
- pixels.each do |pixel|
138
- column = Array.new(HISTOGRAM_ROWS).fill { Pixel.new }
139
- HISTOGRAM_ROWS.times do |y|
140
- column[y] = pixel if y >= HISTOGRAM_ROWS - (hist[pixel] * scale)
141
- end
142
- histogram.store_pixels(x, 0, 1, HISTOGRAM_ROWS, column)
143
- x = x.succ
144
- end
145
-
146
- histogram['Label'] = 'Color Frequency'
147
- return histogram
148
- end
149
- end
150
-
151
- # Use AnnotateImage to write the stats.
152
- def info_text(fg, bg)
153
- klass = class_type == DirectClass ? 'DirectClass' : 'PsuedoClass'
154
-
155
- text = <<-END_TEXT
156
- Format: #{format}
157
- Geometry: #{columns}x#{rows}
158
- Class: #{klass}
159
- Depth: #{depth} bits-per-pixel component
160
- Colors: #{number_colors}
161
- END_TEXT
162
-
163
- info = Image.new(HISTOGRAM_COLS, HISTOGRAM_ROWS) do
164
- self.background_color = bg
165
- self.border_color = fg
166
- end
167
-
168
- gc = Draw.new
169
-
170
- gc.annotate(info, 0, 0, 0, 0, text) do
171
- self.stroke = 'transparent'
172
- self.fill = fg
173
- self.gravity = CenterGravity
174
- end
175
- info['Label'] = 'Info'
176
-
177
- info
178
- end
179
-
180
- def intensity_hist(int_histogram)
181
- gradient = (Image.read('gradient:#ffff80-#ff9000') { self.size = "#{HISTOGRAM_COLS}x#{HISTOGRAM_ROWS}" }).first
182
- int_histogram = gradient.composite(int_histogram, CenterGravity, OverCompositeOp)
183
-
184
- int_histogram['Label'] = 'Intensity'
185
-
186
- int_histogram
187
- end
188
-
189
- # Returns a value between 0 and MAX_QUANTUM. Same as the PixelIntensity macro.
190
- def pixel_intensity(pixel)
191
- (306 * (pixel.red & MAX_QUANTUM) + 601 * (pixel.green & MAX_QUANTUM) + 117 * (pixel.blue & MAX_QUANTUM)) / 1024
192
- end
193
-
194
- public
195
-
196
- # Create the histogram montage.
197
- def histogram(fg = 'white', bg = 'black')
198
- red = Array.new(HISTOGRAM_COLS, 0)
199
- green = Array.new(HISTOGRAM_COLS, 0)
200
- blue = Array.new(HISTOGRAM_COLS, 0)
201
- alpha = Array.new(HISTOGRAM_COLS, 0)
202
- int = Array.new(HISTOGRAM_COLS, 0)
203
-
204
- rows.times do |row|
205
- pixels = get_pixels(0, row, columns, 1)
206
- pixels.each do |pixel|
207
- red[pixel.red & MAX_QUANTUM] += 1
208
- green[pixel.green & MAX_QUANTUM] += 1
209
- blue[pixel.blue & MAX_QUANTUM] += 1
210
-
211
- # Only count opacity channel if some pixels are not opaque.
212
- alpha[pixel.opacity & MAX_QUANTUM] += 1 unless opaque?
213
- v = pixel_intensity(pixel)
214
- int[v] += 1
215
- end
216
- end
217
-
218
- # Scale to chart size. When computing the scale, add some "air" between
219
- # the max frequency and the top of the histogram. This makes a prettier chart.
220
- # The RGBA and intensity histograms are all drawn to the same scale.
221
-
222
- max = [red.max, green.max, blue.max, alpha.max, int.max].max
223
- scale = HISTOGRAM_ROWS / (max * AIR_FACTOR)
224
-
225
- charts = ImageList.new
226
-
227
- # Add the thumbnail.
228
- thumb = copy
229
- thumb['Label'] = File.basename(filename)
230
- charts << thumb
231
-
232
- # Compute the channel and intensity histograms.
233
- channel_hists = channel_histograms(red, green, blue, int, scale, fg, bg)
234
-
235
- # Add the red, green, and blue histograms to the list
236
- charts << channel_hists.shift
237
- charts << channel_hists.shift
238
- charts << channel_hists.shift
239
-
240
- # Add Alpha channel or image stats
241
- charts << if !opaque?
242
- alpha_hist(alpha, scale, fg, bg)
243
- else
244
- info_text(fg, bg)
245
- end
246
-
247
- # Add the RGB histogram
248
- charts << channel_hists.shift
249
-
250
- # Add the intensity histogram.
251
- charts << intensity_hist(channel_hists.shift)
252
-
253
- # Add the color frequency histogram.
254
- charts << color_hist(fg, bg)
255
-
256
- # Make a montage.
257
- histogram = charts.montage do
258
- self.background_color = bg
259
- self.stroke = 'transparent'
260
- self.fill = fg
261
- self.border_width = 1
262
- self.tile = '4x2'
263
- self.geometry = "#{HISTOGRAM_COLS}x#{HISTOGRAM_ROWS}+10+10"
264
- end
265
-
266
- histogram
267
- end
268
- end
269
- end
270
-
271
- puts <<END_INFO
272
-
273
- This example shows how to get pixel-level access to an image.
274
- Usage: histogram.rb <image-filename>
275
-
276
- END_INFO
277
-
278
- # Get filename from command line.
279
- if !ARGV[0]
280
- puts 'No filename argument. Defaulting to Flower_Hat.jpg'
281
- filename = '../doc/ex/images/Flower_Hat.jpg'
282
- else
283
- filename = ARGV[0]
284
- end
285
-
286
- # Only process first frame if multi-frame image
287
- image = Magick::Image.read(filename)
288
- puts 'Charting 1st image' if image.length > 1
289
- image = image.first
290
-
291
- # Give the user something to look at while we're working.
292
- name = File.basename(filename).sub(/\..*?$/, '')
293
- $stdout.sync = true
294
- printf "Creating #{name}_Histogram.png"
295
-
296
- timer = Thread.new do
297
- loop do
298
- sleep(1)
299
- printf '.'
300
- end
301
- end
302
-
303
- # Generate the histograms
304
- histogram = image.histogram(Magick::Pixel.from_color('white'), Magick::Pixel.from_color('black'))
305
-
306
- # Write output file
307
- histogram.compression = Magick::ZipCompression
308
- histogram.write("./#{name}_Histogram.png")
309
-
310
- Thread.kill(timer)
311
- puts 'Done!'
312
- exit
data/examples/identify.rb DELETED
@@ -1,174 +0,0 @@
1
- require 'rmagick'
2
-
3
- module Magick
4
- class Image
5
- # Print information similar to the identify -verbose command
6
- def identify
7
- printf 'Image: '
8
- puts "#{base_filename}=>" if base_filename != filename
9
- puts filename + "\n"
10
- puts "\tFormat: #{format}\n"
11
- puts "\tGeometry: #{columns}x#{rows}\n"
12
- puts "\tClass: #{class_type}\n"
13
- puts "\tType: #{image_type}\n"
14
- puts "\tEndianess: #{endian}\n"
15
- puts "\tColorspace: #{colorspace}\n"
16
- puts "\tChannelDepth:\n"
17
- color_space = gray? ? Magick::GRAYColorspace : colorspace
18
- case color_space
19
- when Magick::RGBColorspace
20
- puts "\t\tRed: #{channel_depth(Magick::RedChannel)}-bits\n"
21
- puts "\t\tGreen: #{channel_depth(Magick::GreenChannel)}-bits\n"
22
- puts "\t\tBlue: #{channel_depth(Magick::BlueChannel)}-bits\n"
23
- puts "\t\tOpacity: #{channel_depth(Magick::OpacityChannel)}-bits\n" if matte
24
- when Magick::CMYKColorspace
25
- puts "\t\tCyan : #{channel_depth(Magick::CyanChannel)}-bits\n"
26
- puts "\t\tMagenta: #{channel_depth(Magick::MagentaChannel)}-bits\n"
27
- puts "\t\tYellow: #{channel_depth(Magick::YellowChannel)}-bits\n"
28
- puts "\t\tBlack: #{channel_depth(Magick::BlackChannel)}-bits\n"
29
- puts "\t\tOpacity: #{channel_depth(Magick::OpacityChannel)}-bits\n" if matte
30
- when Magick::GRAYColorspace
31
- puts "\t\tGray: #{channel_depth(Magick::GrayChannel)}-bits\n"
32
- puts "\t\tOpacity: #{channel_depth(Magick::OpacityChannel)}-bits\n" if matte
33
- end
34
- scale = Magick::QuantumRange / (Magick::QuantumRange >> (Magick::MAGICKCORE_QUANTUM_DEPTH - channel_depth))
35
- puts "\tChannel statistics:\n"
36
- case color_space
37
- when Magick::RGBColorspace
38
- puts "\t\tRed:\n"
39
- puts "\t\t\tMin: " + sprintf("%u (%g)\n", channel_extrema(Magick::RedChannel)[0] / scale, channel_extrema(Magick::RedChannel)[0] / Magick::QuantumRange)
40
- puts "\t\t\tMax: " + sprintf("%u (%g)\n", channel_extrema(Magick::RedChannel)[1] / scale, channel_extrema(Magick::RedChannel)[1] / Magick::QuantumRange)
41
- puts "\t\t\tMean: " + sprintf("%g (%g)\n", channel_mean(Magick::RedChannel)[0] / scale, channel_mean(Magick::RedChannel)[0] / Magick::QuantumRange)
42
- puts "\t\t\tStandard deviation: " + sprintf("%g (%g)\n", channel_mean(Magick::RedChannel)[1] / scale, channel_mean(Magick::RedChannel)[1] / Magick::QuantumRange)
43
- puts "\t\tGreen:\n"
44
- puts "\t\t\tMin: " + sprintf("%u (%g)\n", channel_extrema(Magick::GreenChannel)[0] / scale, channel_extrema(Magick::GreenChannel)[0] / Magick::QuantumRange)
45
- puts "\t\t\tMax: " + sprintf("%u (%g)\n", channel_extrema(Magick::GreenChannel)[1] / scale, channel_extrema(Magick::GreenChannel)[1] / Magick::QuantumRange)
46
- puts "\t\t\tMean: " + sprintf("%g (%g)\n", channel_mean(Magick::GreenChannel)[0] / scale, channel_mean(Magick::GreenChannel)[0] / Magick::QuantumRange)
47
- puts "\t\t\tStandard deviation: " + sprintf("%g (%g)\n", channel_mean(Magick::GreenChannel)[1] / scale, channel_mean(Magick::GreenChannel)[1] / Magick::QuantumRange)
48
- puts "\t\tBlue:\n"
49
- puts "\t\t\tMin: " + sprintf("%u (%g)\n", channel_extrema(Magick::BlueChannel)[0] / scale, channel_extrema(Magick::BlueChannel)[0] / Magick::QuantumRange)
50
- puts "\t\t\tMax: " + sprintf("%u (%g)\n", channel_extrema(Magick::BlueChannel)[1] / scale, channel_extrema(Magick::BlueChannel)[1] / Magick::QuantumRange)
51
- puts "\t\t\tMean: " + sprintf("%g (%g)\n", channel_mean(Magick::BlueChannel)[0] / scale, channel_mean(Magick::BlueChannel)[0] / Magick::QuantumRange)
52
- puts "\t\t\tStandard deviation: " + sprintf("%g (%g)\n", channel_mean(Magick::BlueChannel)[1] / scale, channel_mean(Magick::BlueChannel)[1] / Magick::QuantumRange)
53
- when Magick::CMYKColorspace
54
- puts "\t\tCyan:\n"
55
- puts "\t\t\tMin: " + sprintf("%u (%g)\n", channel_extrema(Magick::CyanChannel)[0] / scale, channel_extrema(Magick::CyanChannel)[0] / Magick::QuantumRange)
56
- puts "\t\t\tMax: " + sprintf("%u (%g)\n", channel_extrema(Magick::CyanChannel)[1] / scale, channel_extrema(Magick::CyanChannel)[1] / Magick::QuantumRange)
57
- puts "\t\t\tMean: " + sprintf("%g (%g)\n", channel_mean(Magick::CyanChannel)[0] / scale, channel_mean(Magick::CyanChannel)[0] / Magick::QuantumRange)
58
- puts "\t\t\tStandard deviation: " + sprintf("%g (%g)\n", channel_mean(Magick::CyanChannel)[1] / scale, channel_mean(Magick::CyanChannel)[1] / Magick::QuantumRange)
59
- puts "\t\tMagenta:\n"
60
- puts "\t\t\tMin: " + sprintf("%u (%g)\n", channel_extrema(Magick::MagentaChannel)[0] / scale, channel_extrema(Magick::MagentaChannel)[0] / Magick::QuantumRange)
61
- puts "\t\t\tMax: " + sprintf("%u (%g)\n", channel_extrema(Magick::MagentaChannel)[1] / scale, channel_extrema(Magick::MagentaChannel)[1] / Magick::QuantumRange)
62
- puts "\t\t\tMean: " + sprintf("%g (%g)\n", channel_mean(Magick::MagentaChannel)[0] / scale, channel_mean(Magick::MagentaChannel)[0] / Magick::QuantumRange)
63
- puts "\t\t\tStandard deviation: " + sprintf("%g (%g)\n", channel_mean(Magick::MagentaChannel)[1] / scale, channel_mean(Magick::MagentaChannel)[1] / Magick::QuantumRange)
64
- puts "\t\tYellow:\n"
65
- puts "\t\t\tMin: " + sprintf("%u (%g)\n", channel_extrema(Magick::YellowChannel)[0] / scale, channel_extrema(Magick::YellowChannel)[0] / Magick::QuantumRange)
66
- puts "\t\t\tMax: " + sprintf("%u (%g)\n", channel_extrema(Magick::YellowChannel)[1] / scale, channel_extrema(Magick::YellowChannel)[1] / Magick::QuantumRange)
67
- puts "\t\t\tMean: " + sprintf("%g (%g)\n", channel_mean(Magick::YellowChannel)[0] / scale, channel_mean(Magick::YellowChannel)[0] / Magick::QuantumRange)
68
- puts "\t\t\tStandard deviation: " + sprintf("%g (%g)\n", channel_mean(Magick::YellowChannel)[1] / scale, channel_mean(Magick::YellowChannel)[1] / Magick::QuantumRange)
69
- puts "\t\tBlack:\n"
70
- puts "\t\t\tMin: " + sprintf("%u (%g)\n", channel_extrema(Magick::BlackChannel)[0] / scale, channel_extrema(Magick::BlackChannel)[0] / Magick::QuantumRange)
71
- puts "\t\t\tMax: " + sprintf("%u (%g)\n", channel_extrema(Magick::BlackChannel)[1] / scale, channel_extrema(Magick::BlackChannel)[1] / Magick::QuantumRange)
72
- puts "\t\t\tMean: " + sprintf("%g (%g)\n", channel_mean(Magick::BlackChannel)[0] / scale, channel_mean(Magick::BlackChannel)[0] / Magick::QuantumRange)
73
- puts "\t\t\tStandard deviation: " + sprintf("%g (%g)\n", channel_mean(Magick::BlackChannel)[1] / scale, channel_mean(Magick::BlackChannel)[1] / Magick::QuantumRange)
74
- when Magick::GRAYColorspace
75
- puts "\t\tGray:\n"
76
- puts "\t\t\tMin: " + sprintf("%u (%g)\n", channel_extrema(Magick::GrayChannel)[0] / scale, channel_extrema(Magick::GrayChannel)[0] / Magick::QuantumRange)
77
- puts "\t\t\tMax: " + sprintf("%u (%g)\n", channel_extrema(Magick::GrayChannel)[1] / scale, channel_extrema(Magick::GrayChannel)[1] / Magick::QuantumRange)
78
- puts "\t\t\tMean: " + sprintf("%g (%g)\n", channel_mean(Magick::GrayChannel)[0] / scale, channel_mean(Magick::GrayChannel)[0] / Magick::QuantumRange)
79
- puts "\t\t\tStandard deviation: " + sprintf("%g (%g)\n", channel_mean(Magick::GrayChannel)[1] / scale, channel_mean(Magick::GrayChannel)[1] / Magick::QuantumRange)
80
- end
81
- if matte
82
- puts "\t\tOpacity:\n"
83
- puts "\t\t\tMin: " + sprintf("%u (%g)\n", channel_extrema(Magick::OpacityChannel)[0] / scale, channel_extrema(Magick::OpacityChannel)[0] / Magick::QuantumRange)
84
- puts "\t\t\tMax: " + sprintf("%u (%g)\n", channel_extrema(Magick::OpacityChannel)[1] / scale, channel_extrema(Magick::OpacityChannel)[1] / Magick::QuantumRange)
85
- puts "\t\t\tMean:" + sprintf("%u (%g)\n", channel_mean(Magick::OpacityChannel)[0] / scale, channel_mean(Magick::OpacityChannel)[0] / Magick::QuantumRange)
86
- puts "\t\t\tStandard deviation:" + sprintf("%u (%g)\n", channel_mean(Magick::OpacityChannel)[1] / scale, channel_mean(Magick::OpacityChannel)[1] / Magick::QuantumRange)
87
- end
88
- if class_type == Magick::DirectClass
89
- puts "\tColors: #{total_colors}\n"
90
- elsif total_colors <= colors
91
- puts "\tColors: #{colors}\n"
92
- else
93
- puts "\tColors: #{total_colors}=>#{colors}\n"
94
- end
95
- # Histogram goes here
96
- puts "\tMean error per pixel: #{mean_error_per_pixel}\n" if mean_error_per_pixel != 0.0
97
- puts "\tNormalized mean error: #{normalized_mean_error}\n" if normalized_mean_error != 0.0
98
- puts "\tNormalized maximum error: #{normalized_maximum_error}\n" if normalized_maximum_error != 0.0
99
- puts "\tRendering-intent: #{rendering_intent}\n"
100
- puts "\tGamma: #{gamma}\n" if gamma != 0.0
101
- chrom = chromaticity
102
- if chrom.red_primary.x != 0.0 || chrom.green_primary.x != 0.0 || chrom.blue_primary.x != 0.0 || chrom.white_point.x != 0.0
103
- puts "\tChromaticity:\n"
104
- puts "\t\tred primary: (#{sprintf('%g,%g', chrom.red_primary.x, chrom.red_primary.y)})\n"
105
- puts "\t\tgreen primary: (#{sprintf('%g,%g', chrom.green_primary.x, chrom.green_primary.y)})\n"
106
- puts "\t\tblue primary: (#{sprintf('%g,%g', chrom.blue_primary.x, chrom.blue_primary.y)})\n"
107
- puts "\t\twhite point: (#{sprintf('%g,%g', chrom.white_point.x, chrom.white_point.y)})\n"
108
- end
109
- ex_info = extract_info
110
- puts "\tTile geometry: #{ex_info.width}x#{ex_info.height}+#{ex_info.x}+#{ex_info.y}\n" if ex_info.width * ex_info.height != 0.0
111
- puts "\tResolution: #{sprintf('%gx%g', x_resolution, y_resolution)}\n" if x_resolution != 0.0 && y_resolution != 0.0
112
- puts "\tUnits: #{units}\n"
113
- size = filesize
114
- if size >= 1_048_576
115
- puts "\tFilesize: #{sprintf('%.1f', (size / 1_048_576.0))}mb\n"
116
- elsif size >= 1024
117
- puts "\tFilesize: #{sprintf('%.0f', (size / 1024.0))}kb\n"
118
- else
119
- puts "\tFilesize: #{size}b\n"
120
- end
121
- puts "\tInterlace: #{interlace}\n"
122
- puts "\tBackground Color: #{background_color}\n"
123
- puts "\tBorder Color: #{border_color}\n"
124
- puts "\tMatte Color: #{matte_color}\n"
125
- pg = page
126
- puts "\tPage geometry: #{pg.width}x#{pg.height}+#{pg.x}+#{pg.y}\n" if pg.width != 0 || pg.height != 0 || pg.x != 0 || pg.y != 0
127
- puts "\tDispose: #{dispose}\n"
128
- puts "\tDelay: #{delay}\n" if delay != 0
129
- puts "\tIterations: #{iterations}\n" unless iterations == 1
130
- puts "\tScene: #{scene}\n" if scene != 0
131
- puts "\tCompression: #{compression}\n"
132
- puts "\tQuality: #{quality}\n" unless quality.zero?
133
- puts "\tOrientation: #{orientation}\n"
134
- puts "\tMontage: #{montage}\n" if montage
135
- signature # compute but ignore - will be displayed along with the other properties
136
- properties.each do |prop, value|
137
- next if prop[0, 1] == '['
138
-
139
- puts "\t#{prop}: #{value}\n"
140
- end
141
- clip_path = self['8BIM:1999,2998:#1']
142
- puts "\tClipping path: #{clip_path}\n" if clip_path
143
- each_profile do |name, value|
144
- puts "\tProfile-#{name}: #{value.length}\n"
145
- next unless name == 'exif'
146
-
147
- exif_attrs = get_exif_by_entry
148
- exif_attrs.each do |attr|
149
- puts "\t\t#{attr[0]}: #{attr[1]}\n"
150
- end
151
- end
152
- puts "\tTainted: True\n" if changed?
153
- puts "\tTainted: False\n" unless changed?
154
- puts "\tVersion: #{Magick::Version}\n"
155
- puts "\t #{Magick::Magick_version}\n"
156
- end
157
- end
158
- end
159
-
160
- if ARGV.length.zero?
161
- puts <<-'END_USAGE'
162
- This example displays information about the specified image file(s)
163
- that is similar to ImageMagick/GraphicsMagick's identify command.
164
-
165
- Usage:
166
- ruby identify.rb filename [filename...]
167
- END_USAGE
168
- exit
169
- end
170
-
171
- ilist = Magick::ImageList.new(*ARGV)
172
- ilist.each(&:identify)
173
-
174
- exit
@@ -1,28 +0,0 @@
1
- # Ccreate a semi-transparent title for an image.
2
-
3
- require 'rmagick'
4
- include Magick
5
-
6
- puts <<END_INFO
7
-
8
- This example uses a semi-transparent background color to create a title.
9
- View the resulting image by entering the command: display image_opacity.miff
10
-
11
- END_INFO
12
-
13
- balloons = Image.read('../doc/ex/images/Hot_Air_Balloons_H.jpg').first
14
- legend = Image.new(160, 50) { self.background_color = '#ffffffc0' }
15
-
16
- gc = Draw.new
17
- gc.annotate(legend, 0, 0, 0, 0, 'Balloon Day!\\nFri May 2 2003') do
18
- self.gravity = CenterGravity
19
- self.stroke = 'transparent'
20
- self.fill = 'white'
21
- self.pointsize = 18
22
- end
23
-
24
- result = balloons.composite(legend, SouthGravity, OverCompositeOp)
25
-
26
- puts '...Writing image_opacity.png'
27
- result.write 'image_opacity.png'
28
- exit
@@ -1,31 +0,0 @@
1
- #
2
- # Demonstrate the export_pixels and import_pixels methods.
3
- #
4
-
5
- require 'rmagick'
6
- include Magick
7
-
8
- puts <<END_INFO
9
-
10
- This example demonstrates the export_pixels and import_pixels methods
11
- by copying an image one row at a time. The result is an copy that
12
- is identical to the original.
13
-
14
- END_INFO
15
-
16
- img = Image.read('../doc/ex/images/Gold_Statue.jpg').first
17
- copy = Image.new(img.columns, img.rows)
18
-
19
- begin
20
- img.rows.times do |r|
21
- scanline = img.export_pixels(0, r, img.columns, 1, 'RGB')
22
- copy.import_pixels(0, r, img.columns, 1, 'RGB', scanline)
23
- end
24
- rescue NotImplementedError
25
- warn 'The export_pixels and import_pixels methods are not supported' \
26
- ' by this version of ImageMagick/GraphicsMagick'
27
- exit
28
- end
29
-
30
- copy.write('copy.gif')
31
- exit
@@ -1,37 +0,0 @@
1
- # Demonstrate ImageMagick's new (5.5.7-3 and later) built-in patterns.
2
- # Create a Fill class that can be reused to fill in new Image backgrounds.
3
-
4
- # Usage: pattern_fill.rb <name-of-pattern>
5
- # Try 'checkerboard' or 'verticalsaw'
6
-
7
- require 'rmagick'
8
- include Magick
9
-
10
- puts <<END_INFO
11
-
12
- This example demonstrates the PATTERN: image format, which is
13
- new in ImageMagick 5.5.7. Specify the name of any of the
14
- supported patterns as an argument. For example, try "checkerboard".
15
-
16
- END_INFO
17
-
18
- class PatternFill < Magick::TextureFill
19
- def initialize(name = 'bricks')
20
- @pat_img = Magick::Image.read("pattern:#{name}").first
21
- super(@pat_img)
22
- end
23
- end
24
-
25
- if ARGV[0]
26
- pattern = ARGV[0]
27
- else
28
- warn 'Defaulting to checkerboard pattern.'
29
- pattern = 'checkerboard'
30
- end
31
-
32
- # Create a sample image that is 100x bigger than the pattern.
33
- attrs = Image.ping("pattern:#{pattern}").first
34
-
35
- tryit = Image.new(10 * attrs.columns, 10 * attrs.rows, PatternFill.new(pattern))
36
- tryit.write('pattern_fill.gif')
37
- exit
@@ -1,45 +0,0 @@
1
- # Demonstrate the Draw#rotation= method by producing
2
- # an animated MIFF file showing a rotating text string.
3
-
4
- require 'rmagick'
5
- include Magick
6
-
7
- puts <<END_INFO
8
- Demonstrate the rotation= attribute in the Draw class
9
- by producing an animated image. View the output image
10
- by entering the command: animate rotating_text.miff
11
- END_INFO
12
-
13
- text = Draw.new
14
- text.pointsize = 28
15
- text.font_weight = BoldWeight
16
- text.font_style = ItalicStyle
17
- text.gravity = CenterGravity
18
- text.fill = 'white'
19
-
20
- # Let's make it interesting. Composite the
21
- # rotated text over a gradient fill background.
22
- fill = GradientFill.new(100, 100, 100, 100, 'yellow', 'red')
23
- bg = Image.new(200, 200, fill)
24
-
25
- # The "none" color is transparent.
26
- fg = Image.new(bg.columns, bg.rows) { self.background_color = 'none' }
27
-
28
- # Here's where we'll collect the individual frames.
29
- animation = ImageList.new
30
-
31
- 0.step(345, 15) do |degrees|
32
- frame = fg.copy
33
- text.annotate(frame, 0, 0, 0, 0, 'Rotating Text') do
34
- self.rotation = degrees
35
- end
36
- # Composite the text over the gradient filled background frame.
37
- animation << bg.composite(frame, CenterGravity, DisplaceCompositeOp)
38
- end
39
-
40
- animation.delay = 8
41
-
42
- # animation.animate
43
- puts '...Writing rotating_text.gif'
44
- animation.write('rotating_text.gif')
45
- exit
data/examples/spinner.rb DELETED
@@ -1,49 +0,0 @@
1
- # Make a 32x32 animated GIF that resembles the OS X animation.
2
- # This produces a very small (~2.6Kb) GIF file.
3
-
4
- require 'rmagick'
5
-
6
- puts <<END_INFO
7
- This example creates an animated GIF that resembles the OS X "waiting" icon.
8
- You can view the GIF with the command
9
-
10
- animate spinner.gif
11
- END_INFO
12
-
13
- NFRAMES = 12 # number of frames in the animation
14
- DIM = 32 # width & height of image in pixels
15
- DELAY = 100.0 / (NFRAMES / 2) # 2 rotations per second
16
-
17
- # 'frame' is a single frame in the animation.
18
- frame = Magick::Image.new(DIM, DIM) { self.background_color = 'transparent' }
19
-
20
- # 'spinner' will contain the frames that make up the animated GIF
21
- spinner = Magick::ImageList.new
22
-
23
- # 'level' is the change from darkest gray to white
24
- level = Magick::QuantumRange / 2 / NFRAMES
25
-
26
- NFRAMES.times do |x|
27
- gc = Magick::Draw.new
28
- gc.translate(DIM / 2, DIM / 2)
29
- gc.stroke('none')
30
- intensity = 0.58 * Magick::QuantumRange
31
- fill_color = Magick::Pixel.new(intensity, intensity, intensity).to_color
32
- gc.fill(fill_color)
33
- angle = x * (360 / NFRAMES)
34
- NFRAMES.times do
35
- gc.rotate(angle)
36
- intensity = [intensity, Magick::QuantumRange].min
37
- fill_color = Magick::Pixel.new(intensity, intensity, intensity).to_color
38
- gc.fill(fill_color)
39
- gc.roundrectangle(7, -1, 15, 0, 1, 1)
40
- angle = -(360 / NFRAMES)
41
- intensity += level
42
- end
43
- spinner << frame.copy
44
- gc.draw(spinner)
45
- end
46
-
47
- spinner.delay = DELAY
48
- spinner.compression = Magick::LZWCompression
49
- spinner.write('spinner.gif')