rmagick 2.13.4 → 2.16.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 (281) hide show
  1. checksums.yaml +4 -4
  2. data/.editorconfig +14 -0
  3. data/.hound.yml +2 -0
  4. data/.rspec +1 -0
  5. data/.rubocop.yml +340 -0
  6. data/.simplecov +27 -0
  7. data/.travis.yml +29 -12
  8. data/CHANGELOG.md +915 -0
  9. data/CODE_OF_CONDUCT.md +13 -0
  10. data/CONTRIBUTING.md +31 -3
  11. data/Gemfile +3 -0
  12. data/README.textile +94 -4
  13. data/Rakefile +57 -45
  14. data/before_install_linux.sh +26 -6
  15. data/deprecated/RMagick.rb +6 -0
  16. data/doc/comtasks.html +1 -1
  17. data/doc/draw.html +7 -4
  18. data/doc/ex/InitialCoords.rb +16 -17
  19. data/doc/ex/NewCoordSys.rb +21 -23
  20. data/doc/ex/OrigCoordSys.rb +8 -10
  21. data/doc/ex/PreserveAspectRatio.rb +182 -183
  22. data/doc/ex/RotateScale.rb +27 -28
  23. data/doc/ex/Skew.rb +27 -27
  24. data/doc/ex/Use01.rb +7 -8
  25. data/doc/ex/Use02.rb +11 -12
  26. data/doc/ex/Use03.rb +7 -7
  27. data/doc/ex/ViewBox.rb +16 -18
  28. data/doc/ex/adaptive_threshold.rb +4 -5
  29. data/doc/ex/add_noise.rb +4 -5
  30. data/doc/ex/affine.rb +4 -4
  31. data/doc/ex/affine_transform.rb +4 -4
  32. data/doc/ex/arc.rb +10 -10
  33. data/doc/ex/arcpath.rb +7 -8
  34. data/doc/ex/arcs01.rb +10 -10
  35. data/doc/ex/arcs02.rb +36 -38
  36. data/doc/ex/average.rb +5 -5
  37. data/doc/ex/axes.rb +4 -4
  38. data/doc/ex/baseline_shift01.rb +11 -12
  39. data/doc/ex/bilevel_channel.rb +2 -3
  40. data/doc/ex/blur_image.rb +2 -2
  41. data/doc/ex/border.rb +2 -2
  42. data/doc/ex/bounding_box.rb +9 -11
  43. data/doc/ex/cbezier1.rb +3 -4
  44. data/doc/ex/cbezier2.rb +3 -4
  45. data/doc/ex/cbezier3.rb +3 -4
  46. data/doc/ex/cbezier4.rb +3 -4
  47. data/doc/ex/cbezier5.rb +2 -3
  48. data/doc/ex/cbezier6.rb +3 -3
  49. data/doc/ex/channel.rb +10 -11
  50. data/doc/ex/charcoal.rb +2 -2
  51. data/doc/ex/chop.rb +2 -2
  52. data/doc/ex/circle.rb +3 -3
  53. data/doc/ex/circle01.rb +6 -7
  54. data/doc/ex/clip_path.rb +12 -12
  55. data/doc/ex/coalesce.rb +32 -35
  56. data/doc/ex/color_fill_to_border.rb +6 -6
  57. data/doc/ex/color_floodfill.rb +2 -2
  58. data/doc/ex/color_histogram.rb +17 -18
  59. data/doc/ex/color_reset.rb +2 -2
  60. data/doc/ex/colorize.rb +2 -2
  61. data/doc/ex/colors.rb +30 -30
  62. data/doc/ex/compose_mask.rb +8 -9
  63. data/doc/ex/composite.rb +14 -16
  64. data/doc/ex/composite_layers.rb +15 -15
  65. data/doc/ex/composite_tiled.rb +5 -7
  66. data/doc/ex/contrast.rb +12 -12
  67. data/doc/ex/crop.rb +3 -3
  68. data/doc/ex/crop_with_gravity.rb +13 -17
  69. data/doc/ex/cubic01.rb +18 -20
  70. data/doc/ex/cubic02.rb +64 -67
  71. data/doc/ex/cycle_colormap.rb +2 -2
  72. data/doc/ex/dissolve.rb +2 -3
  73. data/doc/ex/drawcomp.rb +34 -34
  74. data/doc/ex/drop_shadow.rb +8 -8
  75. data/doc/ex/edge.rb +2 -2
  76. data/doc/ex/ellipse.rb +4 -4
  77. data/doc/ex/ellipse01.rb +10 -11
  78. data/doc/ex/emboss.rb +2 -2
  79. data/doc/ex/enhance.rb +2 -2
  80. data/doc/ex/equalize.rb +2 -2
  81. data/doc/ex/evenodd.rb +31 -32
  82. data/doc/ex/fill_pattern.rb +12 -15
  83. data/doc/ex/flatten_images.rb +13 -13
  84. data/doc/ex/flip.rb +2 -2
  85. data/doc/ex/flop.rb +2 -2
  86. data/doc/ex/font_styles.rb +21 -23
  87. data/doc/ex/fonts.rb +14 -14
  88. data/doc/ex/frame.rb +3 -3
  89. data/doc/ex/gaussian_blur.rb +2 -2
  90. data/doc/ex/get_multiline_type_metrics.rb +6 -7
  91. data/doc/ex/get_pixels.rb +13 -14
  92. data/doc/ex/get_type_metrics.rb +26 -31
  93. data/doc/ex/gradientfill.rb +12 -12
  94. data/doc/ex/grav.rb +4 -5
  95. data/doc/ex/gravity.rb +61 -60
  96. data/doc/ex/group.rb +16 -16
  97. data/doc/ex/hatchfill.rb +10 -10
  98. data/doc/ex/image.rb +29 -31
  99. data/doc/ex/implode.rb +17 -17
  100. data/doc/ex/level.rb +2 -2
  101. data/doc/ex/level_colors.rb +4 -4
  102. data/doc/ex/line.rb +4 -5
  103. data/doc/ex/line01.rb +11 -13
  104. data/doc/ex/mask.rb +7 -8
  105. data/doc/ex/matte_fill_to_border.rb +2 -3
  106. data/doc/ex/matte_floodfill.rb +2 -3
  107. data/doc/ex/matte_replace.rb +2 -3
  108. data/doc/ex/median_filter.rb +2 -2
  109. data/doc/ex/modulate.rb +2 -2
  110. data/doc/ex/mono.rb +4 -4
  111. data/doc/ex/morph.rb +7 -8
  112. data/doc/ex/mosaic.rb +15 -15
  113. data/doc/ex/motion_blur.rb +2 -2
  114. data/doc/ex/negate.rb +2 -2
  115. data/doc/ex/negate_channel.rb +2 -2
  116. data/doc/ex/nested_rvg.rb +11 -11
  117. data/doc/ex/nonzero.rb +31 -32
  118. data/doc/ex/normalize.rb +2 -2
  119. data/doc/ex/oil_paint.rb +2 -2
  120. data/doc/ex/opacity.rb +3 -3
  121. data/doc/ex/ordered_dither.rb +2 -2
  122. data/doc/ex/path.rb +4 -5
  123. data/doc/ex/pattern1.rb +10 -10
  124. data/doc/ex/pattern2.rb +7 -7
  125. data/doc/ex/polaroid.rb +13 -14
  126. data/doc/ex/polygon.rb +6 -7
  127. data/doc/ex/polygon01.rb +10 -12
  128. data/doc/ex/polyline.rb +4 -5
  129. data/doc/ex/polyline01.rb +11 -13
  130. data/doc/ex/posterize.rb +2 -2
  131. data/doc/ex/preview.rb +3 -4
  132. data/doc/ex/qbezierpath.rb +5 -5
  133. data/doc/ex/quad01.rb +23 -25
  134. data/doc/ex/quantize-m.rb +5 -5
  135. data/doc/ex/radial_blur.rb +2 -2
  136. data/doc/ex/raise.rb +2 -2
  137. data/doc/ex/random_threshold_channel.rb +2 -2
  138. data/doc/ex/rect01.rb +6 -7
  139. data/doc/ex/rect02.rb +9 -11
  140. data/doc/ex/rectangle.rb +3 -4
  141. data/doc/ex/reduce_noise.rb +2 -2
  142. data/doc/ex/remap.rb +7 -8
  143. data/doc/ex/remap_images.rb +9 -11
  144. data/doc/ex/resize_to_fill.rb +3 -5
  145. data/doc/ex/resize_to_fit.rb +3 -5
  146. data/doc/ex/roll.rb +2 -2
  147. data/doc/ex/rotate.rb +6 -7
  148. data/doc/ex/rotate_f.rb +2 -2
  149. data/doc/ex/roundrect.rb +4 -5
  150. data/doc/ex/rubyname.rb +11 -11
  151. data/doc/ex/rvg_clippath.rb +5 -7
  152. data/doc/ex/rvg_linecap.rb +25 -26
  153. data/doc/ex/rvg_linejoin.rb +25 -26
  154. data/doc/ex/rvg_opacity.rb +10 -11
  155. data/doc/ex/rvg_pattern.rb +15 -15
  156. data/doc/ex/rvg_stroke_dasharray.rb +6 -7
  157. data/doc/ex/segment.rb +2 -2
  158. data/doc/ex/sepiatone.rb +2 -3
  159. data/doc/ex/shade.rb +2 -2
  160. data/doc/ex/shadow.rb +2 -3
  161. data/doc/ex/shave.rb +2 -2
  162. data/doc/ex/shear.rb +3 -3
  163. data/doc/ex/sketch.rb +2 -3
  164. data/doc/ex/skewx.rb +4 -5
  165. data/doc/ex/skewy.rb +3 -3
  166. data/doc/ex/smile.rb +113 -113
  167. data/doc/ex/solarize.rb +2 -2
  168. data/doc/ex/sparse_color.rb +29 -30
  169. data/doc/ex/splice.rb +2 -3
  170. data/doc/ex/spread.rb +2 -2
  171. data/doc/ex/stegano.rb +34 -34
  172. data/doc/ex/stroke_dasharray.rb +4 -5
  173. data/doc/ex/stroke_fill.rb +4 -5
  174. data/doc/ex/stroke_linecap.rb +3 -3
  175. data/doc/ex/stroke_linejoin.rb +3 -3
  176. data/doc/ex/stroke_width.rb +3 -3
  177. data/doc/ex/swirl.rb +2 -2
  178. data/doc/ex/text.rb +4 -4
  179. data/doc/ex/text01.rb +7 -8
  180. data/doc/ex/text_align.rb +2 -2
  181. data/doc/ex/text_antialias.rb +9 -10
  182. data/doc/ex/text_styles.rb +11 -13
  183. data/doc/ex/text_undercolor.rb +2 -2
  184. data/doc/ex/texture_fill_to_border.rb +6 -6
  185. data/doc/ex/texture_floodfill.rb +2 -2
  186. data/doc/ex/texturefill.rb +10 -11
  187. data/doc/ex/threshold.rb +2 -2
  188. data/doc/ex/to_blob.rb +4 -5
  189. data/doc/ex/translate.rb +6 -6
  190. data/doc/ex/transparent.rb +5 -5
  191. data/doc/ex/transpose.rb +2 -2
  192. data/doc/ex/transverse.rb +2 -2
  193. data/doc/ex/tref01.rb +11 -12
  194. data/doc/ex/triangle01.rb +5 -6
  195. data/doc/ex/trim.rb +1 -2
  196. data/doc/ex/tspan01.rb +8 -9
  197. data/doc/ex/tspan02.rb +9 -11
  198. data/doc/ex/tspan03.rb +9 -11
  199. data/doc/ex/unsharp_mask.rb +2 -2
  200. data/doc/ex/viewex.rb +19 -21
  201. data/doc/ex/vignette.rb +2 -2
  202. data/doc/ex/watermark.rb +15 -16
  203. data/doc/ex/wave.rb +2 -2
  204. data/doc/ex/wet_floor.rb +17 -18
  205. data/doc/ex/writing_mode01.rb +8 -9
  206. data/doc/ex/writing_mode02.rb +8 -8
  207. data/doc/ilist.html +1 -1
  208. data/doc/usage.html +8 -8
  209. data/examples/constitute.rb +6 -6
  210. data/examples/crop_with_gravity.rb +13 -17
  211. data/examples/demo.rb +305 -305
  212. data/examples/describe.rb +27 -28
  213. data/examples/find_similar_region.rb +16 -16
  214. data/examples/histogram.rb +228 -232
  215. data/examples/identify.rb +165 -167
  216. data/examples/image_opacity.rb +4 -4
  217. data/examples/import_export.rb +10 -10
  218. data/examples/pattern_fill.rb +9 -9
  219. data/examples/rotating_text.rb +13 -14
  220. data/examples/spinner.rb +18 -19
  221. data/examples/thumbnail.rb +13 -14
  222. data/examples/vignette.rb +8 -9
  223. data/ext/RMagick/extconf.rb +489 -367
  224. data/ext/RMagick/rmagick.c +11 -4
  225. data/ext/RMagick/rmagick.h +4 -0
  226. data/ext/RMagick/rmdraw.c +49 -18
  227. data/ext/RMagick/rmenum.c +18 -7
  228. data/ext/RMagick/rmfill.c +4 -1
  229. data/ext/RMagick/rmilist.c +49 -13
  230. data/ext/RMagick/rmimage.c +196 -59
  231. data/ext/RMagick/rminfo.c +33 -10
  232. data/ext/RMagick/rmmain.c +18 -6
  233. data/ext/RMagick/rmmontage.c +12 -4
  234. data/ext/RMagick/rmpixel.c +18 -5
  235. data/ext/RMagick/rmstruct.c +108 -31
  236. data/ext/RMagick/rmutil.c +50 -26
  237. data/lib/rmagick/version.rb +4 -3
  238. data/lib/rmagick_internal.rb +1159 -1176
  239. data/lib/rvg/clippath.rb +36 -39
  240. data/lib/rvg/container.rb +115 -124
  241. data/lib/rvg/deep_equal.rb +46 -50
  242. data/lib/rvg/describable.rb +41 -47
  243. data/lib/rvg/embellishable.rb +384 -410
  244. data/lib/rvg/misc.rb +697 -714
  245. data/lib/rvg/paint.rb +42 -47
  246. data/lib/rvg/pathdata.rb +120 -125
  247. data/lib/rvg/rvg.rb +213 -213
  248. data/lib/rvg/stretchable.rb +159 -162
  249. data/lib/rvg/stylable.rb +109 -117
  250. data/lib/rvg/text.rb +9 -24
  251. data/lib/rvg/transformable.rb +120 -127
  252. data/lib/rvg/units.rb +58 -61
  253. data/rmagick.gemspec +46 -15
  254. data/spec/rmagick/ImageList1_spec.rb +24 -0
  255. data/spec/rmagick/draw_spec.rb +156 -0
  256. data/spec/rmagick/image/blue_shift_spec.rb +16 -0
  257. data/spec/rmagick/image/composite_spec.rb +140 -0
  258. data/spec/rmagick/image/constitute_spec.rb +15 -0
  259. data/spec/rmagick/image/dispatch_spec.rb +18 -0
  260. data/spec/rmagick/image/from_blob_spec.rb +14 -0
  261. data/spec/rmagick/image/ping_spec.rb +14 -0
  262. data/spec/rmagick/image/properties_spec.rb +29 -0
  263. data/spec/spec_helper.rb +4 -0
  264. data/test/Image1.rb +529 -727
  265. data/test/Image2.rb +1291 -1299
  266. data/test/Image3.rb +978 -981
  267. data/test/ImageList1.rb +7 -9
  268. data/test/ImageList2.rb +346 -350
  269. data/test/Image_attributes.rb +683 -686
  270. data/test/Import_Export.rb +25 -30
  271. data/test/Info.rb +339 -343
  272. data/test/Magick.rb +250 -253
  273. data/test/Pixel.rb +107 -110
  274. data/test/Preview.rb +48 -53
  275. data/test/test_all_basic.rb +15 -11
  276. data/test/tmpnam_test.rb +3 -3
  277. data/wercker.yml +10 -0
  278. metadata +77 -10
  279. data/ChangeLog +0 -816
  280. data/lib/RMagick.rb +0 -1
  281. data/test/Draw.rb +0 -121
data/examples/identify.rb CHANGED
@@ -1,187 +1,185 @@
1
- require 'RMagick'
1
+ require 'rmagick'
2
2
 
3
3
  module Magick
4
- class Image
5
-
6
- # Print information similar to the identify -verbose command
7
- def identify
8
- printf "Image: "
9
- puts "#{base_filename}=>" if base_filename != filename
10
- puts filename + "\n"
11
- puts "\tFormat: #{format}\n"
12
- puts "\tGeometry: #{columns}x#{rows}\n"
13
- puts "\tClass: #{class_type.to_s}\n"
14
- puts "\tType: #{image_type.to_s}\n"
15
- puts "\tEndianess: #{endian}\n"
16
- puts "\tColorspace: #{colorspace}\n"
17
- puts "\tChannelDepth:\n"
18
- color_space = gray? ? Magick::GrayColorspace : colorspace
19
- case color_space
20
- when Magick::RGBColorspace
21
- puts "\t\tRed: #{channel_depth(Magick::RedChannel)}-bits\n"
22
- puts "\t\tGreen: #{channel_depth(Magick::GreenChannel)}-bits\n"
23
- puts "\t\tBlue: #{channel_depth(Magick::BlueChannel)}-bits\n"
24
- puts "\t\tOpacity: #{channel_depth(Magick::OpacityChannel)}-bits\n" if matte
25
- when Magick::CMYKColorspace
26
- puts "\t\tCyan : #{channel_depth(Magick::CyanChannel)}-bits\n"
27
- puts "\t\tMagenta: #{channel_depth(Magick::MagentaChannel)}-bits\n"
28
- puts "\t\tYellow: #{channel_depth(Magick::YellowChannel)}-bits\n"
29
- puts "\t\tBlack: #{channel_depth(Magick::BlackChannel)}-bits\n"
30
- puts "\t\tOpacity: #{channel_depth(Magick::OpacityChannel)}-bits\n" if matte
31
- when Magick::GrayColorspace
32
- puts "\t\tGray: #{channel_depth(Magick::GrayChannel)}-bits\n"
33
- puts "\t\tOpacity: #{channel_depth(Magick::OpacityChannel)}-bits\n" if matte
34
- end
35
- scale = Magick::QuantumRange / (Magick::QuantumRange >> (Magick::MAGICKCORE_QUANTUM_DEPTH-channel_depth))
36
- puts "\tChannel statistics:\n"
37
- case color_space
38
- when Magick::RGBColorspace
39
- puts "\t\tRed:\n"
40
- puts "\t\t\tMin: " + sprintf("%u (%g)\n", channel_extrema(Magick::RedChannel)[0]/scale, channel_extrema(Magick::RedChannel)[0]/Magick::QuantumRange)
41
- puts "\t\t\tMax: " + sprintf("%u (%g)\n", channel_extrema(Magick::RedChannel)[1]/scale, channel_extrema(Magick::RedChannel)[1]/Magick::QuantumRange)
42
- puts "\t\t\tMean: " + sprintf("%g (%g)\n", channel_mean(Magick::RedChannel)[0]/scale, channel_mean(Magick::RedChannel)[0]/Magick::QuantumRange)
43
- puts "\t\t\tStandard deviation: " + sprintf("%g (%g)\n", channel_mean(Magick::RedChannel)[1]/scale, channel_mean(Magick::RedChannel)[1]/Magick::QuantumRange)
44
- puts "\t\tGreen:\n"
45
- puts "\t\t\tMin: " + sprintf("%u (%g)\n", channel_extrema(Magick::GreenChannel)[0]/scale, channel_extrema(Magick::GreenChannel)[0]/Magick::QuantumRange)
46
- puts "\t\t\tMax: " + sprintf("%u (%g)\n", channel_extrema(Magick::GreenChannel)[1]/scale, channel_extrema(Magick::GreenChannel)[1]/Magick::QuantumRange)
47
- puts "\t\t\tMean: " + sprintf("%g (%g)\n", channel_mean(Magick::GreenChannel)[0]/scale, channel_mean(Magick::GreenChannel)[0]/Magick::QuantumRange)
48
- puts "\t\t\tStandard deviation: " + sprintf("%g (%g)\n", channel_mean(Magick::GreenChannel)[1]/scale, channel_mean(Magick::GreenChannel)[1]/Magick::QuantumRange)
49
- puts "\t\tBlue:\n"
50
- puts "\t\t\tMin: " + sprintf("%u (%g)\n", channel_extrema(Magick::BlueChannel)[0]/scale, channel_extrema(Magick::BlueChannel)[0]/Magick::QuantumRange)
51
- puts "\t\t\tMax: " + sprintf("%u (%g)\n", channel_extrema(Magick::BlueChannel)[1]/scale, channel_extrema(Magick::BlueChannel)[1]/Magick::QuantumRange)
52
- puts "\t\t\tMean: " + sprintf("%g (%g)\n", channel_mean(Magick::BlueChannel)[0]/scale, channel_mean(Magick::BlueChannel)[0]/Magick::QuantumRange)
53
- puts "\t\t\tStandard deviation: " + sprintf("%g (%g)\n", channel_mean(Magick::BlueChannel)[1]/scale, channel_mean(Magick::BlueChannel)[1]/Magick::QuantumRange)
54
- when Magick::CMYKColorspace
55
- puts "\t\tCyan:\n"
56
- puts "\t\t\tMin: " + sprintf("%u (%g)\n", channel_extrema(Magick::CyanChannel)[0]/scale, channel_extrema(Magick::CyanChannel)[0]/Magick::QuantumRange)
57
- puts "\t\t\tMax: " + sprintf("%u (%g)\n", channel_extrema(Magick::CyanChannel)[1]/scale, channel_extrema(Magick::CyanChannel)[1]/Magick::QuantumRange)
58
- puts "\t\t\tMean: " + sprintf("%g (%g)\n", channel_mean(Magick::CyanChannel)[0]/scale, channel_mean(Magick::CyanChannel)[0]/Magick::QuantumRange)
59
- puts "\t\t\tStandard deviation: " + sprintf("%g (%g)\n", channel_mean(Magick::CyanChannel)[1]/scale, channel_mean(Magick::CyanChannel)[1]/Magick::QuantumRange)
60
- puts "\t\tMagenta:\n"
61
- puts "\t\t\tMin: " + sprintf("%u (%g)\n", channel_extrema(Magick::MagentaChannel)[0]/scale, channel_extrema(Magick::MagentaChannel)[0]/Magick::QuantumRange)
62
- puts "\t\t\tMax: " + sprintf("%u (%g)\n", channel_extrema(Magick::MagentaChannel)[1]/scale, channel_extrema(Magick::MagentaChannel)[1]/Magick::QuantumRange)
63
- puts "\t\t\tMean: " + sprintf("%g (%g)\n", channel_mean(Magick::MagentaChannel)[0]/scale, channel_mean(Magick::MagentaChannel)[0]/Magick::QuantumRange)
64
- puts "\t\t\tStandard deviation: " + sprintf("%g (%g)\n", channel_mean(Magick::MagentaChannel)[1]/scale, channel_mean(Magick::MagentaChannel)[1]/Magick::QuantumRange)
65
- puts "\t\tYellow:\n"
66
- puts "\t\t\tMin: " + sprintf("%u (%g)\n", channel_extrema(Magick::YellowChannel)[0]/scale, channel_extrema(Magick::YellowChannel)[0]/Magick::QuantumRange)
67
- puts "\t\t\tMax: " + sprintf("%u (%g)\n", channel_extrema(Magick::YellowChannel)[1]/scale, channel_extrema(Magick::YellowChannel)[1]/Magick::QuantumRange)
68
- puts "\t\t\tMean: " + sprintf("%g (%g)\n", channel_mean(Magick::YellowChannel)[0]/scale, channel_mean(Magick::YellowChannel)[0]/Magick::QuantumRange)
69
- puts "\t\t\tStandard deviation: " + sprintf("%g (%g)\n", channel_mean(Magick::YellowChannel)[1]/scale, channel_mean(Magick::YellowChannel)[1]/Magick::QuantumRange)
70
- puts "\t\tBlack:\n"
71
- puts "\t\t\tMin: " + sprintf("%u (%g)\n", channel_extrema(Magick::BlackChannel)[0]/scale, channel_extrema(Magick::BlackChannel)[0]/Magick::QuantumRange)
72
- puts "\t\t\tMax: " + sprintf("%u (%g)\n", channel_extrema(Magick::BlackChannel)[1]/scale, channel_extrema(Magick::BlackChannel)[1]/Magick::QuantumRange)
73
- puts "\t\t\tMean: " + sprintf("%g (%g)\n", channel_mean(Magick::BlackChannel)[0]/scale, channel_mean(Magick::BlackChannel)[0]/Magick::QuantumRange)
74
- puts "\t\t\tStandard deviation: " + sprintf("%g (%g)\n", channel_mean(Magick::BlackChannel)[1]/scale, channel_mean(Magick::BlackChannel)[1]/Magick::QuantumRange)
75
- when Magick::GrayColorspace
76
- puts "\t\tGray:\n"
77
- puts "\t\t\tMin: " + sprintf("%u (%g)\n", channel_extrema(Magick::GrayChannel)[0]/scale, channel_extrema(Magick::GrayChannel)[0]/Magick::QuantumRange)
78
- puts "\t\t\tMax: " + sprintf("%u (%g)\n", channel_extrema(Magick::GrayChannel)[1]/scale, channel_extrema(Magick::GrayChannel)[1]/Magick::QuantumRange)
79
- puts "\t\t\tMean: " + sprintf("%g (%g)\n", channel_mean(Magick::GrayChannel)[0]/scale, channel_mean(Magick::GrayChannel)[0]/Magick::QuantumRange)
80
- puts "\t\t\tStandard deviation: " + sprintf("%g (%g)\n", channel_mean(Magick::GrayChannel)[1]/scale, channel_mean(Magick::GrayChannel)[1]/Magick::QuantumRange)
81
- end
82
- if matte
83
- puts "\t\tOpacity:\n"
84
- puts "\t\t\tMin: " + sprintf("%u (%g)\n", channel_extrema(Magick::OpacityChannel)[0]/scale, channel_extrema(Magick::OpacityChannel)[0]/Magick::QuantumRange)
85
- puts "\t\t\tMax: " + sprintf("%u (%g)\n", channel_extrema(Magick::OpacityChannel)[1]/scale, channel_extrema(Magick::OpacityChannel)[1]/Magick::QuantumRange)
86
- puts "\t\t\tMean:" + sprintf("%u (%g)\n", channel_mean(Magick::OpacityChannel)[0]/scale, channel_mean(Magick::OpacityChannel)[0]/Magick::QuantumRange)
87
- puts "\t\t\tStandard deviation:" + sprintf("%u (%g)\n", channel_mean(Magick::OpacityChannel)[1]/scale, channel_mean(Magick::OpacityChannel)[1]/Magick::QuantumRange)
88
- end
89
- if class_type == Magick::DirectClass
90
- puts "\tColors: #{total_colors}\n"
91
- else
92
- if total_colors <= colors
93
- puts "\tColors: #{colors}\n"
94
- else
95
- puts "\tColors: #{total_colors}=>#{colors}\n"
96
- end
97
- end
98
- # Histogram goes here
99
- puts "\tMean error per pixel: #{mean_error_per_pixel}\n" if mean_error_per_pixel != 0.0
100
- puts "\tNormalized mean error: #{normalized_mean_error}\n" if normalized_mean_error != 0.0
101
- puts "\tNormalized maximum error: #{normalized_maximum_error}\n" if normalized_maximum_error != 0.0
102
- puts "\tRendering-intent: #{rendering_intent.to_s}\n"
103
- puts "\tGamma: #{gamma}\n" if gamma != 0.0
104
- chrom = chromaticity
105
- 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
106
- puts "\tChromaticity:\n"
107
- puts "\t\tred primary: (#{sprintf("%g,%g", chrom.red_primary.x, chrom.red_primary.y)})\n"
108
- puts "\t\tgreen primary: (#{sprintf("%g,%g", chrom.green_primary.x, chrom.green_primary.y)})\n"
109
- puts "\t\tblue primary: (#{sprintf("%g,%g", chrom.blue_primary.x, chrom.blue_primary.y)})\n"
110
- puts "\t\twhite point: (#{sprintf("%g,%g", chrom.white_point.x, chrom.white_point.y)})\n"
111
- end
112
- ex_info = extract_info
113
- if ex_info.width * ex_info.height != 0.0
114
- puts "\tTile geometry: #{ex_info.width}x#{ex_info.height}+#{ex_info.x}+#{ex_info.y}\n"
115
- end
116
- if x_resolution != 0.0 && y_resolution != 0.0
117
- puts "\tResolution: #{sprintf("%gx%g", x_resolution, y_resolution)}\n"
118
- end
119
- puts "\tUnits: #{units.to_s}\n"
120
- size = filesize
121
- if size >= 1048576
122
- puts "\tFilesize: #{"%.1f" % (size/1048576.0)}mb\n"
123
- elsif size >= 1024
124
- puts "\tFilesize: #{"%.0f" % (size/1024.0)}kb\n"
125
- else
126
- puts "\tFilesize: #{size}b\n"
127
- end
128
- puts "\tInterlace: #{interlace.to_s}\n"
129
- puts "\tBackground Color: #{background_color}\n"
130
- puts "\tBorder Color: #{border_color}\n"
131
- puts "\tMatte Color: #{matte_color}\n"
132
- pg = page
133
- if pg.width != 0 || pg.height != 0 || pg.x != 0 || pg.y != 0
134
- puts "\tPage geometry: #{pg.width}x#{pg.height}+#{pg.x}+#{pg.y}\n"
135
- end
136
- puts "\tDispose: #{dispose.to_s}\n"
137
- puts "\tDelay: #{delay}\n" if delay != 0
138
- puts "\tIterations: #{iterations}\n" unless iterations == 1
139
- puts "\tScene: #{scene}\n" if scene != 0
140
- puts "\tCompression: #{compression.to_s}\n"
141
- puts "\tQuality: #{quality}\n" unless quality == 0
142
- puts "\tOrientation: #{orientation.to_s}\n"
143
- puts "\tMontage: #{montage}\n" if montage
144
- signature # compute but ignore - will be displayed along with the other properties
145
- properties.each do |prop, value|
146
- next if prop[0,1] == '['
147
- puts "\t#{prop}: #{value}\n"
148
- end
149
- clip_path = self["8BIM:1999,2998:#1"]
150
- if clip_path
151
- puts "\tClipping path: #{clip_path}\n"
152
- end
153
- each_profile do |name, value|
154
- puts "\tProfile-#{name}: #{value.length}\n"
155
- if name == 'exif'
156
- exif_attrs = get_exif_by_entry
157
- exif_attrs.each do |attr|
158
- puts "\t\t#{attr[0]}: #{attr[1]}\n"
159
- end
160
- end
161
- end
162
- puts "\tTainted: True\n" if changed?
163
- puts "\tTainted: False\n" unless changed?
164
- puts "\tVersion: #{Magick::Version}\n"
165
- puts "\t #{Magick::Magick_version}\n"
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
+ else
91
+ if total_colors <= colors
92
+ puts "\tColors: #{colors}\n"
93
+ else
94
+ puts "\tColors: #{total_colors}=>#{colors}\n"
95
+ end
96
+ end
97
+ # Histogram goes here
98
+ puts "\tMean error per pixel: #{mean_error_per_pixel}\n" if mean_error_per_pixel != 0.0
99
+ puts "\tNormalized mean error: #{normalized_mean_error}\n" if normalized_mean_error != 0.0
100
+ puts "\tNormalized maximum error: #{normalized_maximum_error}\n" if normalized_maximum_error != 0.0
101
+ puts "\tRendering-intent: #{rendering_intent}\n"
102
+ puts "\tGamma: #{gamma}\n" if gamma != 0.0
103
+ chrom = chromaticity
104
+ 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
105
+ puts "\tChromaticity:\n"
106
+ puts "\t\tred primary: (#{sprintf('%g,%g', chrom.red_primary.x, chrom.red_primary.y)})\n"
107
+ puts "\t\tgreen primary: (#{sprintf('%g,%g', chrom.green_primary.x, chrom.green_primary.y)})\n"
108
+ puts "\t\tblue primary: (#{sprintf('%g,%g', chrom.blue_primary.x, chrom.blue_primary.y)})\n"
109
+ puts "\t\twhite point: (#{sprintf('%g,%g', chrom.white_point.x, chrom.white_point.y)})\n"
110
+ end
111
+ ex_info = extract_info
112
+ if ex_info.width * ex_info.height != 0.0
113
+ puts "\tTile geometry: #{ex_info.width}x#{ex_info.height}+#{ex_info.x}+#{ex_info.y}\n"
114
+ end
115
+ if x_resolution != 0.0 && y_resolution != 0.0
116
+ puts "\tResolution: #{sprintf('%gx%g', x_resolution, y_resolution)}\n"
117
+ end
118
+ puts "\tUnits: #{units}\n"
119
+ size = filesize
120
+ if size >= 1048576
121
+ puts "\tFilesize: #{'%.1f' % (size/1048576.0)}mb\n"
122
+ elsif size >= 1024
123
+ puts "\tFilesize: #{'%.0f' % (size/1024.0)}kb\n"
124
+ else
125
+ puts "\tFilesize: #{size}b\n"
126
+ end
127
+ puts "\tInterlace: #{interlace}\n"
128
+ puts "\tBackground Color: #{background_color}\n"
129
+ puts "\tBorder Color: #{border_color}\n"
130
+ puts "\tMatte Color: #{matte_color}\n"
131
+ pg = page
132
+ if pg.width != 0 || pg.height != 0 || pg.x != 0 || pg.y != 0
133
+ puts "\tPage geometry: #{pg.width}x#{pg.height}+#{pg.x}+#{pg.y}\n"
134
+ end
135
+ puts "\tDispose: #{dispose}\n"
136
+ puts "\tDelay: #{delay}\n" if delay != 0
137
+ puts "\tIterations: #{iterations}\n" unless iterations == 1
138
+ puts "\tScene: #{scene}\n" if scene != 0
139
+ puts "\tCompression: #{compression}\n"
140
+ puts "\tQuality: #{quality}\n" unless quality == 0
141
+ puts "\tOrientation: #{orientation}\n"
142
+ puts "\tMontage: #{montage}\n" if montage
143
+ signature # compute but ignore - will be displayed along with the other properties
144
+ properties.each do |prop, value|
145
+ next if prop[0,1] == '['
146
+ puts "\t#{prop}: #{value}\n"
147
+ end
148
+ clip_path = self['8BIM:1999,2998:#1']
149
+ if clip_path
150
+ puts "\tClipping path: #{clip_path}\n"
151
+ end
152
+ each_profile do |name, value|
153
+ puts "\tProfile-#{name}: #{value.length}\n"
154
+ if name == 'exif'
155
+ exif_attrs = get_exif_by_entry
156
+ exif_attrs.each do |attr|
157
+ puts "\t\t#{attr[0]}: #{attr[1]}\n"
158
+ end
166
159
  end
160
+ end
161
+ puts "\tTainted: True\n" if changed?
162
+ puts "\tTainted: False\n" unless changed?
163
+ puts "\tVersion: #{Magick::Version}\n"
164
+ puts "\t #{Magick::Magick_version}\n"
167
165
  end
166
+ end
168
167
  end
169
168
 
170
169
  if ARGV.length == 0
171
- puts <<-'END_USAGE'
170
+ puts <<-'END_USAGE'
172
171
  This example displays information about the specified image file(s)
173
172
  that is similar to ImageMagick/GraphicsMagick's identify command.
174
173
 
175
174
  Usage:
176
175
  ruby identify.rb filename [filename...]
177
176
  END_USAGE
178
- exit
177
+ exit
179
178
  end
180
179
 
181
180
  ilist = Magick::ImageList.new(*ARGV)
182
181
  ilist.each do |img|
183
- img.identify
182
+ img.identify
184
183
  end
185
184
 
186
185
  exit
187
-
@@ -1,7 +1,7 @@
1
1
 
2
2
  # Ccreate a semi-transparent title for an image.
3
3
 
4
- require 'RMagick'
4
+ require 'rmagick'
5
5
  include Magick
6
6
 
7
7
  puts <<END_INFO
@@ -15,15 +15,15 @@ balloons = Image.read('../doc/ex/images/Hot_Air_Balloons_H.jpg').first
15
15
  legend = Image.new(160, 50) { self.background_color = '#ffffffc0' }
16
16
 
17
17
  gc = Draw.new
18
- gc.annotate(legend, 0, 0, 0, 0, "Balloon Day!\\nFri May 2 2003") {
18
+ gc.annotate(legend, 0, 0, 0, 0, 'Balloon Day!\\nFri May 2 2003') do
19
19
  self.gravity = CenterGravity
20
20
  self.stroke = 'transparent'
21
21
  self.fill = 'white'
22
22
  self.pointsize = 18
23
- }
23
+ end
24
24
 
25
25
  result = balloons.composite(legend, SouthGravity, OverCompositeOp)
26
26
 
27
- puts "...Writing image_opacity.miff"
27
+ puts '...Writing image_opacity.miff'
28
28
  result.write 'image_opacity.miff'
29
29
  exit
@@ -2,7 +2,7 @@
2
2
  # Demonstrate the export_pixels and import_pixels methods.
3
3
  #
4
4
 
5
- require 'RMagick'
5
+ require 'rmagick'
6
6
  include Magick
7
7
 
8
8
  puts <<END_INFO
@@ -14,18 +14,18 @@ is identical to the original.
14
14
  END_INFO
15
15
 
16
16
  img = Image.read('../doc/ex/images/Gold_Statue.jpg').first
17
- copy = Image.new(img.columns, img.rows);
17
+ copy = Image.new(img.columns, img.rows)
18
18
 
19
19
  begin
20
- img.rows.times { |r|
21
- scanline = img.export_pixels(0, r, img.columns, 1, "RGB");
22
- copy.import_pixels(0, r, img.columns, 1, "RGB", scanline);
23
- }
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
24
  rescue NotImplementedError
25
- $stderr.puts "The export_pixels and import_pixels methods are not supported" +
26
- " by this version of ImageMagick/GraphicsMagick"
27
- exit
25
+ $stderr.puts 'The export_pixels and import_pixels methods are not supported' \
26
+ ' by this version of ImageMagick/GraphicsMagick'
27
+ exit
28
28
  end
29
29
 
30
- copy.write("copy.gif")
30
+ copy.write('copy.gif')
31
31
  exit
@@ -5,7 +5,7 @@
5
5
  # Usage: pattern_fill.rb <name-of-pattern>
6
6
  # Try 'checkerboard' or 'verticalsaw'
7
7
 
8
- require 'RMagick'
8
+ require 'rmagick'
9
9
  include Magick
10
10
 
11
11
  puts <<END_INFO
@@ -17,22 +17,22 @@ supported patterns as an argument. For example, try "checkerboard".
17
17
  END_INFO
18
18
 
19
19
  class PatternFill < Magick::TextureFill
20
- def initialize(name='bricks')
21
- @pat_img = Magick::Image.read("pattern:#{name}").first
22
- super(@pat_img)
23
- end
20
+ def initialize(name='bricks')
21
+ @pat_img = Magick::Image.read("pattern:#{name}").first
22
+ super(@pat_img)
23
+ end
24
24
  end
25
25
 
26
26
  if ARGV[0]
27
- pattern = ARGV[0]
27
+ pattern = ARGV[0]
28
28
  else
29
- $stderr.puts "Defaulting to checkerboard pattern."
30
- pattern = 'checkerboard'
29
+ $stderr.puts 'Defaulting to checkerboard pattern.'
30
+ pattern = 'checkerboard'
31
31
  end
32
32
 
33
33
  # Create a sample image that is 100x bigger than the pattern.
34
34
  attrs = Image.ping("pattern:#{pattern}").first
35
35
 
36
36
  tryit = Image.new(10*attrs.columns, 10*attrs.rows, PatternFill.new(pattern))
37
- tryit.write("pattern_fill.gif")
37
+ tryit.write('pattern_fill.gif')
38
38
  exit
@@ -1,8 +1,7 @@
1
1
  # Demonstrate the Draw#rotation= method by producing
2
2
  # an animated MIFF file showing a rotating text string.
3
3
 
4
-
5
- require 'RMagick'
4
+ require 'rmagick'
6
5
  include Magick
7
6
 
8
7
  puts <<END_INFO
@@ -19,27 +18,27 @@ text.gravity = CenterGravity
19
18
 
20
19
  # Let's make it interesting. Composite the
21
20
  # rotated text over a gradient fill background.
22
- fill = GradientFill.new(100,100,100,100,"yellow","red")
21
+ fill = GradientFill.new(100,100,100,100,'yellow','red')
23
22
  bg = Image.new(200, 200, fill)
24
23
 
25
24
  # The "none" color is transparent.
26
- fg = Image.new(bg.columns, bg.rows) { self.background_color = "none" }
25
+ fg = Image.new(bg.columns, bg.rows) { self.background_color = 'none' }
27
26
 
28
27
  # Here's where we'll collect the individual frames.
29
28
  animation = ImageList.new
30
29
 
31
- 0.step(345,15) { |degrees|
32
- frame = fg.copy
33
- text.annotate(frame, 0,0,0,0, "Rotating Text") {
34
- self.rotation = degrees
35
- }
36
- # Composite the text over the gradient filled background frame.
37
- animation << bg.composite(frame, CenterGravity, DisplaceCompositeOp)
38
- }
30
+ 0.step(345,15) do |degrees|
31
+ frame = fg.copy
32
+ text.annotate(frame, 0,0,0,0, 'Rotating Text') do
33
+ self.rotation = degrees
34
+ end
35
+ # Composite the text over the gradient filled background frame.
36
+ animation << bg.composite(frame, CenterGravity, DisplaceCompositeOp)
37
+ end
39
38
 
40
39
  animation.delay = 8
41
40
 
42
41
  #animation.animate
43
- puts "...Writing rotating_text.gif"
44
- animation.write("rotating_text.gif")
42
+ puts '...Writing rotating_text.gif'
43
+ animation.write('rotating_text.gif')
45
44
  exit
data/examples/spinner.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  # Make a 32x32 animated GIF that resembles the OS X animation.
2
2
  # This produces a very small (~2.6Kb) GIF file.
3
3
 
4
- require 'RMagick'
4
+ require 'rmagick'
5
5
 
6
6
  puts <<END_INFO
7
7
  This example creates an animated GIF that resembles the OS X "waiting" icon.
@@ -10,7 +10,6 @@ You can view the GIF with the command
10
10
  animate spinner.gif
11
11
  END_INFO
12
12
 
13
-
14
13
  NFRAMES = 12 # number of frames in the animation
15
14
  DIM = 32 # width & height of image in pixels
16
15
  DELAY = 100.0 / (NFRAMES/2) # 2 rotations per second
@@ -25,26 +24,26 @@ spinner = Magick::ImageList.new
25
24
  level = Magick::QuantumRange / 2 / NFRAMES
26
25
 
27
26
  NFRAMES.times do |x|
28
- gc = Magick::Draw.new
29
- gc.translate(DIM/2, DIM/2)
30
- gc.stroke('none')
31
- intensity = 0.58 * Magick::QuantumRange
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
32
37
  fill_color = Magick::Pixel.new(intensity, intensity, intensity).to_color
33
38
  gc.fill(fill_color)
34
- angle = x * (360/NFRAMES)
35
- NFRAMES.times do
36
- gc.rotate(angle)
37
- intensity = [intensity, Magick::QuantumRange].min
38
- fill_color = Magick::Pixel.new(intensity, intensity, intensity).to_color
39
- gc.fill(fill_color)
40
- gc.roundrectangle(7, -1, 15, 0, 1, 1)
41
- angle = -(360/NFRAMES)
42
- intensity += level
43
- end
44
- spinner << frame.copy
45
- gc.draw(spinner)
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)
46
45
  end
47
46
 
48
47
  spinner.delay = DELAY
49
48
  spinner.compression = Magick::LZWCompression
50
- spinner.write('spinner.gif')
49
+ spinner.write('spinner.gif')