rmagick 2.16.0 → 3.0.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 (238) hide show
  1. checksums.yaml +5 -5
  2. data/.appveyor.yml +19 -0
  3. data/.circleci/config.yml +56 -0
  4. data/.rubocop.yml +8 -335
  5. data/.rubocop_todo.yml +255 -0
  6. data/.ruby-version +1 -0
  7. data/.travis.yml +6 -49
  8. data/CHANGELOG.md +23 -0
  9. data/CONTRIBUTING.md +34 -0
  10. data/Gemfile +0 -6
  11. data/README.textile +11 -3
  12. data/Rakefile +23 -15
  13. data/before_install_linux.sh +12 -15
  14. data/doc/ex/InitialCoords.rb +4 -4
  15. data/doc/ex/NewCoordSys.rb +4 -4
  16. data/doc/ex/OrigCoordSys.rb +2 -2
  17. data/doc/ex/PreserveAspectRatio.rb +34 -34
  18. data/doc/ex/RotateScale.rb +7 -7
  19. data/doc/ex/Skew.rb +7 -7
  20. data/doc/ex/Use01.rb +1 -1
  21. data/doc/ex/Use02.rb +4 -4
  22. data/doc/ex/Use03.rb +2 -2
  23. data/doc/ex/ViewBox.rb +4 -4
  24. data/doc/ex/affine.rb +5 -5
  25. data/doc/ex/affine_transform.rb +3 -3
  26. data/doc/ex/arc.rb +9 -9
  27. data/doc/ex/arcpath.rb +2 -2
  28. data/doc/ex/arcs01.rb +6 -6
  29. data/doc/ex/arcs02.rb +8 -8
  30. data/doc/ex/axes.rb +11 -11
  31. data/doc/ex/baseline_shift01.rb +5 -5
  32. data/doc/ex/bilevel_channel.rb +1 -1
  33. data/doc/ex/blur_image.rb +1 -1
  34. data/doc/ex/border.rb +1 -1
  35. data/doc/ex/bounding_box.rb +11 -11
  36. data/doc/ex/cbezier1.rb +12 -12
  37. data/doc/ex/cbezier2.rb +13 -13
  38. data/doc/ex/cbezier3.rb +13 -13
  39. data/doc/ex/cbezier4.rb +13 -13
  40. data/doc/ex/cbezier5.rb +13 -13
  41. data/doc/ex/cbezier6.rb +19 -19
  42. data/doc/ex/channel.rb +2 -2
  43. data/doc/ex/chop.rb +2 -2
  44. data/doc/ex/circle.rb +7 -7
  45. data/doc/ex/circle01.rb +2 -2
  46. data/doc/ex/clip_path.rb +6 -6
  47. data/doc/ex/coalesce.rb +6 -6
  48. data/doc/ex/color_fill_to_border.rb +8 -8
  49. data/doc/ex/color_floodfill.rb +8 -8
  50. data/doc/ex/color_histogram.rb +2 -2
  51. data/doc/ex/color_reset.rb +2 -2
  52. data/doc/ex/colors.rb +4 -4
  53. data/doc/ex/compose_mask.rb +2 -2
  54. data/doc/ex/composite.rb +39 -39
  55. data/doc/ex/composite_layers.rb +1 -2
  56. data/doc/ex/contrast.rb +3 -3
  57. data/doc/ex/crop.rb +2 -2
  58. data/doc/ex/crop_with_gravity.rb +5 -5
  59. data/doc/ex/cubic01.rb +12 -12
  60. data/doc/ex/cubic02.rb +22 -22
  61. data/doc/ex/cycle_colormap.rb +3 -3
  62. data/doc/ex/dissolve.rb +0 -0
  63. data/doc/ex/drawcomp.rb +8 -9
  64. data/doc/ex/drop_shadow.rb +4 -4
  65. data/doc/ex/ellipse.rb +9 -9
  66. data/doc/ex/ellipse01.rb +3 -3
  67. data/doc/ex/enhance.rb +2 -2
  68. data/doc/ex/evenodd.rb +19 -19
  69. data/doc/ex/fill_pattern.rb +3 -3
  70. data/doc/ex/flatten_images.rb +1 -1
  71. data/doc/ex/font_styles.rb +13 -13
  72. data/doc/ex/fonts.rb +2 -6
  73. data/doc/ex/frame.rb +1 -1
  74. data/doc/ex/get_multiline_type_metrics.rb +3 -3
  75. data/doc/ex/get_pixels.rb +4 -6
  76. data/doc/ex/get_type_metrics.rb +26 -25
  77. data/doc/ex/gradientfill.rb +2 -2
  78. data/doc/ex/grav.rb +12 -12
  79. data/doc/ex/gravity.rb +14 -16
  80. data/doc/ex/group.rb +11 -11
  81. data/doc/ex/hatchfill.rb +2 -2
  82. data/doc/ex/image.rb +9 -9
  83. data/doc/ex/implode.rb +2 -2
  84. data/doc/ex/line.rb +10 -10
  85. data/doc/ex/line01.rb +7 -7
  86. data/doc/ex/mask.rb +0 -0
  87. data/doc/ex/matte_fill_to_border.rb +3 -3
  88. data/doc/ex/matte_floodfill.rb +2 -2
  89. data/doc/ex/matte_replace.rb +3 -3
  90. data/doc/ex/median_filter.rb +2 -2
  91. data/doc/ex/mono.rb +2 -2
  92. data/doc/ex/morph.rb +1 -1
  93. data/doc/ex/mosaic.rb +7 -5
  94. data/doc/ex/motion_blur.rb +1 -1
  95. data/doc/ex/negate_channel.rb +0 -0
  96. data/doc/ex/nested_rvg.rb +2 -2
  97. data/doc/ex/nonzero.rb +19 -19
  98. data/doc/ex/opacity.rb +9 -9
  99. data/doc/ex/path.rb +17 -17
  100. data/doc/ex/pattern1.rb +4 -4
  101. data/doc/ex/pattern2.rb +2 -2
  102. data/doc/ex/polaroid.rb +0 -1
  103. data/doc/ex/polygon.rb +7 -7
  104. data/doc/ex/polygon01.rb +7 -7
  105. data/doc/ex/polyline.rb +7 -7
  106. data/doc/ex/polyline01.rb +8 -8
  107. data/doc/ex/posterize.rb +0 -0
  108. data/doc/ex/qbezierpath.rb +16 -16
  109. data/doc/ex/quad01.rb +6 -6
  110. data/doc/ex/quantize-m.rb +2 -2
  111. data/doc/ex/random_threshold_channel.rb +1 -1
  112. data/doc/ex/rect01.rb +2 -2
  113. data/doc/ex/rect02.rb +3 -3
  114. data/doc/ex/rectangle.rb +6 -6
  115. data/doc/ex/reduce_noise.rb +2 -2
  116. data/doc/ex/remap.rb +0 -0
  117. data/doc/ex/resize_to_fill.rb +0 -0
  118. data/doc/ex/resize_to_fit.rb +0 -0
  119. data/doc/ex/roll.rb +1 -1
  120. data/doc/ex/rotate.rb +8 -8
  121. data/doc/ex/rotate_f.rb +1 -1
  122. data/doc/ex/roundrect.rb +6 -6
  123. data/doc/ex/rubyname.rb +4 -4
  124. data/doc/ex/rvg_clippath.rb +3 -3
  125. data/doc/ex/rvg_linecap.rb +7 -7
  126. data/doc/ex/rvg_linejoin.rb +7 -7
  127. data/doc/ex/rvg_opacity.rb +5 -5
  128. data/doc/ex/rvg_pattern.rb +8 -8
  129. data/doc/ex/rvg_stroke_dasharray.rb +2 -2
  130. data/doc/ex/sepiatone.rb +0 -0
  131. data/doc/ex/shadow.rb +6 -6
  132. data/doc/ex/shear.rb +2 -2
  133. data/doc/ex/skewx.rb +8 -8
  134. data/doc/ex/skewy.rb +9 -9
  135. data/doc/ex/smile.rb +5 -4
  136. data/doc/ex/sparse_color.rb +0 -4
  137. data/doc/ex/splice.rb +1 -1
  138. data/doc/ex/stegano.rb +4 -5
  139. data/doc/ex/stroke_dasharray.rb +10 -10
  140. data/doc/ex/stroke_fill.rb +2 -2
  141. data/doc/ex/stroke_linecap.rb +12 -12
  142. data/doc/ex/stroke_linejoin.rb +12 -12
  143. data/doc/ex/stroke_width.rb +11 -11
  144. data/doc/ex/swirl.rb +2 -2
  145. data/doc/ex/text.rb +6 -6
  146. data/doc/ex/text01.rb +4 -4
  147. data/doc/ex/text_align.rb +5 -5
  148. data/doc/ex/text_antialias.rb +2 -2
  149. data/doc/ex/text_styles.rb +8 -8
  150. data/doc/ex/text_undercolor.rb +4 -4
  151. data/doc/ex/texture_fill_to_border.rb +8 -8
  152. data/doc/ex/texture_floodfill.rb +8 -8
  153. data/doc/ex/texturefill.rb +2 -2
  154. data/doc/ex/threshold.rb +2 -2
  155. data/doc/ex/to_blob.rb +1 -1
  156. data/doc/ex/translate.rb +8 -8
  157. data/doc/ex/transparent.rb +6 -6
  158. data/doc/ex/transpose.rb +0 -0
  159. data/doc/ex/transverse.rb +0 -0
  160. data/doc/ex/tref01.rb +6 -6
  161. data/doc/ex/triangle01.rb +2 -2
  162. data/doc/ex/trim.rb +2 -2
  163. data/doc/ex/tspan01.rb +5 -5
  164. data/doc/ex/tspan02.rb +5 -5
  165. data/doc/ex/tspan03.rb +5 -5
  166. data/doc/ex/unsharp_mask.rb +3 -3
  167. data/doc/ex/viewex.rb +5 -5
  168. data/doc/ex/vignette.rb +0 -0
  169. data/doc/ex/watermark.rb +6 -6
  170. data/doc/ex/wet_floor.rb +2 -2
  171. data/doc/ex/writing_mode01.rb +12 -12
  172. data/doc/ex/writing_mode02.rb +12 -12
  173. data/examples/constitute.rb +1 -1
  174. data/examples/crop_with_gravity.rb +5 -5
  175. data/examples/demo.rb +6 -7
  176. data/examples/describe.rb +8 -10
  177. data/examples/find_similar_region.rb +3 -3
  178. data/examples/histogram.rb +192 -201
  179. data/examples/identify.rb +62 -73
  180. data/examples/image_opacity.rb +0 -1
  181. data/examples/import_export.rb +1 -1
  182. data/examples/pattern_fill.rb +3 -4
  183. data/examples/rotating_text.rb +5 -4
  184. data/examples/spinner.rb +5 -5
  185. data/examples/thumbnail.rb +3 -3
  186. data/examples/vignette.rb +5 -5
  187. data/ext/RMagick/extconf.rb +213 -230
  188. data/ext/RMagick/rmagick.c +1 -0
  189. data/ext/RMagick/rmagick.h +26 -29
  190. data/ext/RMagick/rmdraw.c +3 -38
  191. data/ext/RMagick/rmenum.c +36 -0
  192. data/ext/RMagick/rmimage.c +166 -10
  193. data/ext/RMagick/rminfo.c +7 -2
  194. data/ext/RMagick/rmkinfo.c +247 -0
  195. data/ext/RMagick/rmmain.c +96 -0
  196. data/ext/RMagick/rmutil.c +4 -0
  197. data/lib/rmagick/version.rb +3 -3
  198. data/lib/rmagick_internal.rb +226 -308
  199. data/lib/rvg/clippath.rb +2 -4
  200. data/lib/rvg/container.rb +25 -22
  201. data/lib/rvg/deep_equal.rb +11 -11
  202. data/lib/rvg/describable.rb +2 -2
  203. data/lib/rvg/embellishable.rb +60 -66
  204. data/lib/rvg/misc.rb +122 -128
  205. data/lib/rvg/pathdata.rb +15 -17
  206. data/lib/rvg/rvg.rb +41 -44
  207. data/lib/rvg/stretchable.rb +22 -28
  208. data/lib/rvg/stylable.rb +10 -10
  209. data/lib/rvg/text.rb +164 -165
  210. data/lib/rvg/transformable.rb +15 -15
  211. data/lib/rvg/units.rb +2 -2
  212. data/rmagick.gemspec +9 -33
  213. data/spec/rmagick/draw_spec.rb +5 -6
  214. data/spec/rmagick/image/blue_shift_spec.rb +1 -3
  215. data/spec/rmagick/image/channel_entropy_spec.rb +9 -0
  216. data/spec/rmagick/image/composite_spec.rb +2 -4
  217. data/spec/rmagick/image/constitute_spec.rb +2 -4
  218. data/spec/rmagick/image/dispatch_spec.rb +1 -3
  219. data/spec/rmagick/image/from_blob_spec.rb +1 -3
  220. data/spec/rmagick/image/ping_spec.rb +1 -3
  221. data/spec/rmagick/image/properties_spec.rb +0 -2
  222. data/spec/rmagick/image/read_spec.rb +28 -0
  223. data/spec/spec_helper.rb +7 -1
  224. data/spec/support/issue_200/app.rb +8 -0
  225. data/test/Image1.rb +70 -70
  226. data/test/Image2.rb +369 -361
  227. data/test/Image3.rb +64 -63
  228. data/test/ImageList1.rb +796 -792
  229. data/test/ImageList2.rb +43 -44
  230. data/test/Image_attributes.rb +26 -48
  231. data/test/Import_Export.rb +71 -77
  232. data/test/Info.rb +30 -31
  233. data/test/Magick.rb +47 -46
  234. data/test/Pixel.rb +24 -24
  235. data/test/Preview.rb +7 -6
  236. data/test/test_all_basic.rb +15 -7
  237. data/test/tmpnam_test.rb +3 -3
  238. metadata +57 -18
@@ -2,18 +2,18 @@ require 'rvg/rvg'
2
2
 
3
3
  Magick::RVG.dpi = 90
4
4
 
5
- rvg = Magick::RVG.new(10.cm, 3.cm).viewbox(0,0,1000,300) do |canvas|
5
+ rvg = Magick::RVG.new(10.cm, 3.cm).viewbox(0, 0, 1000, 300) do |canvas|
6
6
  canvas.background_fill = 'white'
7
7
 
8
8
  canvas.g.translate(100, 60) do |grp|
9
- grp.text.styles(:font_family=>'Verdana', :font_size=>45) do |txt|
9
+ grp.text.styles(font_family: 'Verdana', font_size: 45) do |txt|
10
10
  txt.tspan('Rotation')
11
- txt.tspan(' propogates').rotate(20).styles(:fill=>'red') do |tsp|
12
- tsp.tspan(' to descendents').styles(:fill=>'green')
11
+ txt.tspan(' propogates').rotate(20).styles(fill: 'red') do |tsp|
12
+ tsp.tspan(' to descendents').styles(fill: 'green')
13
13
  end
14
14
  end
15
15
  end
16
- canvas.rect(997, 297).styles(:fill=>'none', :stroke=>'blue')
16
+ canvas.rect(997, 297).styles(fill: 'none', stroke: 'blue')
17
17
  end
18
18
 
19
19
  rvg.draw.write('tspan03.gif')
@@ -11,18 +11,18 @@ img.resize!(3)
11
11
  eimg.resize!(3)
12
12
 
13
13
  # Make a before-and-after composite
14
- eimg.crop!(eimg.columns/2, 0, eimg.columns/2, eimg.rows)
14
+ eimg.crop!(eimg.columns / 2, 0, eimg.columns / 2, eimg.rows)
15
15
  img = img.composite(eimg, Magick::EastGravity, Magick::OverCompositeOp)
16
16
 
17
17
  # Draw a black line between the before and after parts.
18
18
  line = Magick::Draw.new
19
- line.line(img.columns/2, 0, img.columns/2, img.rows)
19
+ line.line(img.columns / 2, 0, img.columns / 2, img.rows)
20
20
  line.draw(img)
21
21
 
22
22
  # Zoom in so we can see the change,
23
23
  # then crop everything but the face.
24
24
  img.crop!(Magick::CenterGravity, 250, 200)
25
25
 
26
- #img.display
26
+ # img.display
27
27
  img.write('unsharp_mask.jpg')
28
28
  exit
@@ -2,7 +2,7 @@
2
2
 
3
3
  require 'rmagick'
4
4
 
5
- img = Magick::Image.new(40, 40) {self.background_color = 'lightcyan2'}
5
+ img = Magick::Image.new(40, 40) { self.background_color = 'lightcyan2' }
6
6
 
7
7
  # The view is 400 pixels square, starting
8
8
  # column 10, row 5 from the top of the image.
@@ -12,21 +12,21 @@ img.view(10, 5, 20, 20) do |view|
12
12
 
13
13
  # Change the top and bottom rows to red.
14
14
  view[0][] = 'red'
15
- view[-1,1][] = 'red'
15
+ view[-1, 1][] = 'red'
16
16
 
17
17
  # Set 6 pixels to black.
18
- view[[13,15]][[12,14,16]] = 'black'
18
+ view[[13, 15]][[12, 14, 16]] = 'black'
19
19
 
20
20
  # Set 1 pixel to yellow.
21
21
  view[5][7] = 'yellow'
22
22
 
23
23
  # Change the green channel of all the
24
24
  # pixels on row 8.
25
- view[8][].green = Magick::QuantumRange/2
25
+ view[8][].green = Magick::QuantumRange / 2
26
26
 
27
27
  # Change the blue channel of 8 pixels
28
28
  # on column 10.
29
- view[4,8][10].blue = Magick::QuantumRange
29
+ view[4, 8][10].blue = Magick::QuantumRange
30
30
  end
31
31
 
32
32
  img.scale(5).write('viewex.gif')
File without changes
@@ -5,17 +5,17 @@ require 'rmagick'
5
5
  img = Magick::Image.read('images/Flower_Hat.jpg').first
6
6
 
7
7
  # Make a watermark from the word "RMagick"
8
- mark = Magick::Image.new(140, 40) {self.background_color = 'none'}
8
+ mark = Magick::Image.new(140, 40) { self.background_color = 'none' }
9
9
  gc = Magick::Draw.new
10
10
 
11
11
  gc.annotate(mark, 0, 0, 0, -5, 'RMagick') do
12
12
  gc.gravity = Magick::CenterGravity
13
13
  gc.pointsize = 32
14
- if RUBY_PLATFORM =~ /mswin32/
15
- gc.font_family = 'Georgia'
16
- else
17
- gc.font_family = 'Times'
18
- end
14
+ gc.font_family = if RUBY_PLATFORM =~ /mswin32/
15
+ 'Georgia'
16
+ else
17
+ 'Times'
18
+ end
19
19
  gc.fill = 'white'
20
20
  gc.stroke = 'none'
21
21
  end
@@ -4,7 +4,7 @@ require 'rmagick'
4
4
 
5
5
  results = Magick::ImageList.new
6
6
 
7
- img = Magick::Image.new(270, 60) {self.background_color = 'black' }
7
+ img = Magick::Image.new(270, 60) { self.background_color = 'black' }
8
8
 
9
9
  gc = Magick::Draw.new
10
10
  gc.annotate(img, 0, 0, 0, -15, 'RUBY!') do
@@ -40,7 +40,7 @@ ilist[1] = img.wet_floor(0.25, 0.5)
40
40
  results << ilist.append(true)
41
41
 
42
42
  # Add a slant
43
- xform = Magick::AffineMatrix.new(1.0, 0.0, Math::PI/4.0, 1.0, 0.0, 0.0)
43
+ xform = Magick::AffineMatrix.new(1.0, 0.0, Math::PI / 4.0, 1.0, 0.0, 0.0)
44
44
  ilist[1] = ilist[1].affine_transform(xform)
45
45
  results << ilist.append(true)
46
46
 
@@ -2,25 +2,25 @@ require 'rvg/rvg'
2
2
 
3
3
  Magick::RVG.dpi = 90
4
4
 
5
- TEXT_STYLES = {:writing_mode=>'tb',
6
- :glyph_orientation_vertical=>0,
7
- :fill=>'red4',
8
- :font_weight=>'bold',
9
- :font_size=>16}
5
+ TEXT_STYLES = { writing_mode: 'tb',
6
+ glyph_orientation_vertical: 0,
7
+ fill: 'red4',
8
+ font_weight: 'bold',
9
+ font_size: 16 }
10
10
 
11
- TEXT_STYLES2 = {:writing_mode=>'tb',
12
- :glyph_orientation_vertical=>90,
13
- :fill=>'green',
14
- :font_weight=>'bold',
15
- :font_size=>16}
11
+ TEXT_STYLES2 = { writing_mode: 'tb',
12
+ glyph_orientation_vertical: 90,
13
+ fill: 'green',
14
+ font_weight: 'bold',
15
+ font_size: 16 }
16
16
 
17
- rvg = Magick::RVG.new(1.25.in, 7.in).viewbox(0,0,125,700) do |canvas|
17
+ rvg = Magick::RVG.new(1.25.in, 7.in).viewbox(0, 0, 125, 700) do |canvas|
18
18
  canvas.background_fill = 'white'
19
19
 
20
20
  canvas.text(40, 15, ':glyph_orientation_vertical=0').styles(TEXT_STYLES)
21
21
  canvas.text(80, 25, ':glyph_orientation_vertical=90').styles(TEXT_STYLES2)
22
22
 
23
- canvas.rect(124, 698).styles(:fill=>'none',:stroke=>'blue')
23
+ canvas.rect(124, 698).styles(fill: 'none', stroke: 'blue')
24
24
  end
25
25
 
26
26
  rvg.draw.write('writing_mode01.gif')
@@ -2,25 +2,25 @@ require 'rvg/rvg'
2
2
 
3
3
  Magick::RVG.dpi = 90
4
4
 
5
- TEXT_STYLES = {:writing_mode=>'lr',
6
- :glyph_orientation_horizontal=>0,
7
- :fill=>'red4',
8
- :font_weight=>'bold',
9
- :font_size=>16}
5
+ TEXT_STYLES = { writing_mode: 'lr',
6
+ glyph_orientation_horizontal: 0,
7
+ fill: 'red4',
8
+ font_weight: 'bold',
9
+ font_size: 16 }
10
10
 
11
- TEXT_STYLES2 = {:writing_mode=>'lr',
12
- :glyph_orientation_horizontal=>180,
13
- :fill=>'green',
14
- :font_weight=>'bold',
15
- :font_size=>16}
11
+ TEXT_STYLES2 = { writing_mode: 'lr',
12
+ glyph_orientation_horizontal: 180,
13
+ fill: 'green',
14
+ font_weight: 'bold',
15
+ font_size: 16 }
16
16
 
17
- rvg = Magick::RVG.new(3.in, 1.in).viewbox(0,0,300,100) do |canvas|
17
+ rvg = Magick::RVG.new(3.in, 1.in).viewbox(0, 0, 300, 100) do |canvas|
18
18
  canvas.background_fill = 'white'
19
19
 
20
20
  canvas.text(15, 40, ':glyph_orientation_horizontal=0').styles(TEXT_STYLES)
21
21
  canvas.text(15, 80, ':glyph_orientation_horizontal=180').styles(TEXT_STYLES2)
22
22
 
23
- canvas.rect(299, 99).styles(:fill=>'none',:stroke=>'blue')
23
+ canvas.rect(299, 99).styles(fill: 'none', stroke: 'blue')
24
24
  end
25
25
 
26
26
  rvg.draw.write('writing_mode02.gif')
@@ -2,6 +2,6 @@
2
2
  require 'rmagick'
3
3
 
4
4
  f = Magick::Image.read('../doc/ex/images/Flower_Hat.jpg').first
5
- pixels = f.dispatch(0,0,f.columns, f.rows, 'RGB')
5
+ pixels = f.dispatch(0, 0, f.columns, f.rows, 'RGB')
6
6
  image = Magick::Image.constitute(f.columns, f.rows, 'RGB', pixels)
7
7
  image.write('constitute.miff')
@@ -12,13 +12,13 @@ include Magick
12
12
 
13
13
  shorts = Image.read('../doc/ex/images/Shorts.jpg').first
14
14
 
15
- regwidth = shorts.columns/2
16
- regheight = shorts.rows/2
15
+ regwidth = shorts.columns / 2
16
+ regheight = shorts.rows / 2
17
17
 
18
- mask = Image.new(regwidth, regheight) { self.background_color = 'white'}
18
+ mask = Image.new(regwidth, regheight) { self.background_color = 'white' }
19
19
  mask.opacity = 0.50 * TransparentOpacity
20
20
 
21
- black = Image.new(shorts.columns, shorts.rows) {self.background_color = 'black'}
21
+ black = Image.new(shorts.columns, shorts.rows) { self.background_color = 'black' }
22
22
  pairs = ImageList.new
23
23
 
24
24
  [NorthWestGravity, NorthGravity, NorthEastGravity,
@@ -39,4 +39,4 @@ montage = pairs.montage do
39
39
  self.border_width = 1
40
40
  end
41
41
  montage.write('crop_with_gravity.miff')
42
- #montage.display
42
+ # montage.display
@@ -37,7 +37,7 @@ begin
37
37
  # optional "size" attribute in the parm block associated with
38
38
  # the read method. There are two more examples of this, below.
39
39
  example = ImageList.new
40
- 5.times { example.read('NULL:black') { self.size = '70x70'} }
40
+ 5.times { example.read('NULL:black') { self.size = '70x70' } }
41
41
 
42
42
  puts ' add noise...'
43
43
  example << model.add_noise(LaplacianNoise)
@@ -80,7 +80,7 @@ begin
80
80
  example.cur_image[:Label] = 'Contrast'
81
81
 
82
82
  puts ' convolve...'
83
- kernel = [ 1, 1, 1, 1, 4, 1, 1, 1, 1 ]
83
+ kernel = [1, 1, 1, 1, 4, 1, 1, 1, 1]
84
84
  example << model.convolve(3, kernel)
85
85
  example.cur_image[:Label] = 'Convolve'
86
86
 
@@ -100,7 +100,7 @@ begin
100
100
  gc.fill_opacity 0
101
101
  gc.stroke 'gold'
102
102
  gc.stroke_width 2
103
- gc.circle 60,90, 60,120
103
+ gc.circle 60, 90, 60, 120
104
104
  gc.draw(example)
105
105
 
106
106
  puts ' edge...'
@@ -277,7 +277,7 @@ begin
277
277
  self.gravity = CenterGravity
278
278
  self.border_width = 1
279
279
  rows = (example.size + 4) / 5
280
- self.tile = Geometry.new(5,rows)
280
+ self.tile = Geometry.new(5, rows)
281
281
  self.compose = OverCompositeOp
282
282
 
283
283
  # Use the ImageMagick built-in "granite" format
@@ -298,7 +298,7 @@ begin
298
298
  puts 'Adding logo image...'
299
299
  logo = Image.read('logo:').first
300
300
  if /GraphicsMagick/.match Magick_version
301
- logo.resize!(200.0/logo.rows)
301
+ logo.resize!(200.0 / logo.rows)
302
302
  else
303
303
  logo.crop!(98, 0, 461, 455).resize!(0.45)
304
304
  end
@@ -316,8 +316,7 @@ begin
316
316
  # Uncomment the following lines to display image to screen
317
317
  # puts "Displaying image..."
318
318
  # montage_image.display
319
-
320
- rescue
319
+ rescue StandardError
321
320
  puts "Caught exception: #{$ERROR_INFO}"
322
321
  end
323
322
 
@@ -1,4 +1,3 @@
1
-
2
1
  # Purpose: Demonstrate getting information from the image attributes.
3
2
  # Usage: describe.rb filename1 [filename2...]
4
3
  # Notes: The output is similar to ImageMagick's identify command.
@@ -11,7 +10,7 @@ This example shows how to extract attributes from an image.
11
10
 
12
11
  END_INFO
13
12
 
14
- if ARGV.length == 0
13
+ if ARGV.length.zero?
15
14
  puts 'Specify one or more image filenames as arguments.'
16
15
  exit
17
16
  end
@@ -31,13 +30,12 @@ ARGV.each do |file|
31
30
  puts " Colors: #{img.number_colors}"
32
31
  puts " Filesize: #{img.filesize}"
33
32
  puts " Resolution: #{img.x_resolution.to_i}x#{img.y_resolution.to_i} "\
34
- "pixels/#{img.units == Magick::PixelsPerInchResolution ?
35
- 'inch' : 'centimeter'}"
36
-
37
- if img.properties.length > 0
38
- puts ' Properties:'
39
- img.properties do |name,value|
40
- puts %Q| #{name} = "#{value}"|
41
- end
33
+ "pixels/#{img.units == Magick::PixelsPerInchResolution ? 'inch' : 'centimeter'}"
34
+
35
+ next if img.properties.empty?
36
+
37
+ puts ' Properties:'
38
+ img.properties do |name, value|
39
+ puts %( #{name} = "#{value}")
42
40
  end
43
41
  end
@@ -16,7 +16,7 @@ begin
16
16
  gc.stroke('red')
17
17
  gc.stroke_width(2)
18
18
  gc.fill('none')
19
- gc.rectangle(res[0], res[1], res[0]+target.columns, res[1]+target.rows)
19
+ gc.rectangle(res[0], res[1], res[0] + target.columns, res[1] + target.rows)
20
20
  gc.draw(img)
21
21
  img.matte = false
22
22
  puts "Found similar region. Writing `find_similar_region.gif'..."
@@ -25,10 +25,10 @@ begin
25
25
  puts 'No match!'
26
26
  end
27
27
  rescue NotImplementedError
28
- $stderr.puts <<-END_MSG
28
+ warn <<-END_MSG
29
29
  The find_similar_region method is not supported by this version of
30
30
  ImageMagick/GraphicsMagick.
31
- END_MSG
31
+ END_MSG
32
32
  end
33
33
 
34
34
  exit
@@ -7,11 +7,11 @@ require 'rmagick'
7
7
  class PixelColumn < Array
8
8
  def initialize(size)
9
9
  super
10
- fill {Magick::Pixel.new}
10
+ fill { Magick::Pixel.new }
11
11
  end
12
12
 
13
13
  def reset(bg)
14
- each {|pixel| pixel.reset(bg)}
14
+ each { |pixel| pixel.reset(bg) }
15
15
  end
16
16
  end
17
17
 
@@ -28,250 +28,243 @@ module Magick
28
28
  class Image
29
29
  private
30
30
 
31
- HISTOGRAM_COLS = 256
32
- HISTOGRAM_ROWS = 200
33
- MAX_QUANTUM = 255
34
- AIR_FACTOR = 1.025
31
+ HISTOGRAM_COLS = 256
32
+ HISTOGRAM_ROWS = 200
33
+ MAX_QUANTUM = 255
34
+ AIR_FACTOR = 1.025
35
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
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
42
 
43
- gc = Draw.new
44
- gc.affine(1, 0, 0, -scale, 0, HISTOGRAM_ROWS)
45
- gc.fill('white')
43
+ gc = Draw.new
44
+ gc.affine(1, 0, 0, -scale, 0, HISTOGRAM_ROWS)
45
+ gc.fill('white')
46
46
 
47
- HISTOGRAM_COLS.times do |x|
48
- gc.point(x, freqs[x])
49
- end
47
+ HISTOGRAM_COLS.times do |x|
48
+ gc.point(x, freqs[x])
49
+ end
50
50
 
51
- gc.draw(histogram)
52
- histogram['Label'] = 'Alpha'
51
+ gc.draw(histogram)
52
+ histogram['Label'] = 'Alpha'
53
53
 
54
- histogram
55
- end
54
+ histogram
55
+ end
56
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.matte = true
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
- if yf >= HISTOGRAM_ROWS - (int[x] * scale)
101
- int_column[y].opacity = TransparentOpacity
102
- end
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.matte = true
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
103
87
  end
104
-
105
- rgb_histogram.store_pixels( x, 0, 1, HISTOGRAM_ROWS, rgb_column)
106
- red_histogram.store_pixels( x, 0, 1, HISTOGRAM_ROWS, red_column)
107
- green_histogram.store_pixels(x, 0, 1, HISTOGRAM_ROWS, green_column)
108
- blue_histogram.store_pixels( x, 0, 1, HISTOGRAM_ROWS, blue_column)
109
- int_histogram.store_pixels( x, 0, 1, HISTOGRAM_ROWS, int_column)
110
- rgb_column.reset(bg)
111
- red_column.reset(bg)
112
- green_column.reset(bg)
113
- blue_column.reset(bg)
114
- int_column.reset(bg)
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)
115
101
  end
116
102
 
117
- [red_histogram, green_histogram, blue_histogram, rgb_histogram, int_histogram]
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)
118
113
  end
119
114
 
120
- # Make the color histogram. Quantize the image to 256 colors if necessary.
121
- def color_hist(fg, bg)
122
- img = number_colors > 256 ? quantize(256) : self
115
+ [red_histogram, green_histogram, blue_histogram, rgb_histogram, int_histogram]
116
+ end
123
117
 
124
- begin
125
- hist = img.color_histogram
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
126
124
  rescue NotImplementedError
127
- $stderr.puts 'The color_histogram method is not supported by this version '\
125
+ warn 'The color_histogram method is not supported by this version '\
128
126
  'of ImageMagick/GraphicsMagick'
127
+ else
128
+ pixels = hist.keys.sort_by { |pixel| hist[pixel] }
129
+ scale = HISTOGRAM_ROWS / (hist.values.max * AIR_FACTOR)
129
130
 
130
- else
131
- pixels = hist.keys.sort_by {|pixel| hist[pixel] }
132
- scale = HISTOGRAM_ROWS / (hist.values.max*AIR_FACTOR)
133
-
134
- histogram = Image.new(HISTOGRAM_COLS, HISTOGRAM_ROWS) do
135
- self.background_color = bg
136
- self.border_color = fg
137
- end
138
-
139
- x = 0
140
- pixels.each do |pixel|
141
- column = Array.new(HISTOGRAM_ROWS).fill {Pixel.new}
142
- HISTOGRAM_ROWS.times do |y|
143
- if y >= HISTOGRAM_ROWS - (hist[pixel] * scale)
144
- column[y] = pixel
145
- end
146
- end
147
- histogram.store_pixels(x, 0, 1, HISTOGRAM_ROWS, column)
148
- x = x.succ
149
- end
131
+ histogram = Image.new(HISTOGRAM_COLS, HISTOGRAM_ROWS) do
132
+ self.background_color = bg
133
+ self.border_color = fg
134
+ end
150
135
 
151
- histogram['Label'] = 'Color Frequency'
152
- return histogram
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
153
144
  end
145
+
146
+ histogram['Label'] = 'Color Frequency'
147
+ return histogram
154
148
  end
149
+ end
155
150
 
156
- # Use AnnotateImage to write the stats.
157
- def info_text(fg, bg)
158
- klass = class_type == DirectClass ? 'DirectClass' : 'PsuedoClass'
151
+ # Use AnnotateImage to write the stats.
152
+ def info_text(fg, bg)
153
+ klass = class_type == DirectClass ? 'DirectClass' : 'PsuedoClass'
159
154
 
160
- text = <<-END_TEXT
155
+ text = <<-END_TEXT
161
156
  Format: #{format}
162
157
  Geometry: #{columns}x#{rows}
163
158
  Class: #{klass}
164
159
  Depth: #{depth} bits-per-pixel component
165
160
  Colors: #{number_colors}
166
- END_TEXT
167
-
168
- info = Image.new(HISTOGRAM_COLS, HISTOGRAM_ROWS) do
169
- self.background_color = bg
170
- self.border_color = fg
171
- end
161
+ END_TEXT
172
162
 
173
- gc = Draw.new
163
+ info = Image.new(HISTOGRAM_COLS, HISTOGRAM_ROWS) do
164
+ self.background_color = bg
165
+ self.border_color = fg
166
+ end
174
167
 
175
- gc.annotate(info, 0, 0, 0, 0, text) do
176
- self.stroke = 'transparent'
177
- self.fill = fg
178
- self.gravity = CenterGravity
179
- end
180
- info['Label'] = 'Info'
168
+ gc = Draw.new
181
169
 
182
- info
170
+ gc.annotate(info, 0, 0, 0, 0, text) do
171
+ self.stroke = 'transparent'
172
+ self.fill = fg
173
+ self.gravity = CenterGravity
183
174
  end
175
+ info['Label'] = 'Info'
184
176
 
185
- def intensity_hist(int_histogram)
186
- gradient = (Image.read('gradient:#ffff80-#ff9000') { self.size="#{HISTOGRAM_COLS}x#{HISTOGRAM_ROWS}" }).first
187
- int_histogram = gradient.composite(int_histogram, CenterGravity, OverCompositeOp)
177
+ info
178
+ end
188
179
 
189
- int_histogram['Label'] = 'Intensity'
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)
190
183
 
191
- int_histogram
192
- end
184
+ int_histogram['Label'] = 'Intensity'
193
185
 
194
- # Returns a value between 0 and MAX_QUANTUM. Same as the PixelIntensity macro.
195
- def pixel_intensity(pixel)
196
- (306*(pixel.red & MAX_QUANTUM) + 601*(pixel.green & MAX_QUANTUM) + 117*(pixel.blue & MAX_QUANTUM))/1024
197
- end
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
198
193
 
199
194
  public
200
195
 
201
- # Create the histogram montage.
202
- def histogram(fg='white', bg='black')
203
- red = Array.new(HISTOGRAM_COLS, 0)
204
- green = Array.new(HISTOGRAM_COLS, 0)
205
- blue = Array.new(HISTOGRAM_COLS, 0)
206
- alpha = Array.new(HISTOGRAM_COLS, 0)
207
- int = Array.new(HISTOGRAM_COLS, 0)
208
-
209
- rows.times do |row|
210
- pixels = get_pixels(0, row, columns, 1)
211
- pixels.each do |pixel|
212
- red[pixel.red & MAX_QUANTUM] += 1
213
- green[pixel.green & MAX_QUANTUM] += 1
214
- blue[pixel.blue & MAX_QUANTUM] += 1
215
-
216
- # Only count opacity channel if some pixels are not opaque.
217
- unless opaque?
218
- alpha[pixel.opacity & MAX_QUANTUM] += 1
219
- end
220
- v = pixel_intensity(pixel)
221
- int[v] += 1
222
- end
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
223
215
  end
216
+ end
224
217
 
225
- # Scale to chart size. When computing the scale, add some "air" between
226
- # the max frequency and the top of the histogram. This makes a prettier chart.
227
- # The RGBA and intensity histograms are all drawn to the same scale.
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.
228
221
 
229
- max = [red.max, green.max, blue.max, alpha.max, int.max].max
230
- scale = HISTOGRAM_ROWS / (max*AIR_FACTOR)
222
+ max = [red.max, green.max, blue.max, alpha.max, int.max].max
223
+ scale = HISTOGRAM_ROWS / (max * AIR_FACTOR)
231
224
 
232
- charts = ImageList.new
225
+ charts = ImageList.new
233
226
 
234
- # Add the thumbnail.
235
- thumb = copy
236
- thumb['Label'] = File.basename(filename)
237
- charts << thumb
227
+ # Add the thumbnail.
228
+ thumb = copy
229
+ thumb['Label'] = File.basename(filename)
230
+ charts << thumb
238
231
 
239
- # Compute the channel and intensity histograms.
240
- channel_hists = channel_histograms(red, green, blue, int, scale, fg, bg)
232
+ # Compute the channel and intensity histograms.
233
+ channel_hists = channel_histograms(red, green, blue, int, scale, fg, bg)
241
234
 
242
- # Add the red, green, and blue histograms to the list
243
- charts << channel_hists.shift
244
- charts << channel_hists.shift
245
- charts << channel_hists.shift
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
246
239
 
247
- # Add Alpha channel or image stats
248
- if !opaque?
249
- charts << alpha_hist(alpha, scale, fg, bg)
250
- else
251
- charts << info_text(fg, bg)
252
- end
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
253
246
 
254
- # Add the RGB histogram
255
- charts << channel_hists.shift
247
+ # Add the RGB histogram
248
+ charts << channel_hists.shift
256
249
 
257
- # Add the intensity histogram.
258
- charts << intensity_hist(channel_hists.shift)
250
+ # Add the intensity histogram.
251
+ charts << intensity_hist(channel_hists.shift)
259
252
 
260
- # Add the color frequency histogram.
261
- charts << color_hist(fg, bg)
253
+ # Add the color frequency histogram.
254
+ charts << color_hist(fg, bg)
262
255
 
263
- # Make a montage.
264
- histogram = charts.montage do
265
- self.background_color = bg
266
- self.stroke = 'transparent'
267
- self.fill = fg
268
- self.border_width = 1
269
- self.tile = '4x2'
270
- self.geometry = "#{HISTOGRAM_COLS}x#{HISTOGRAM_ROWS}+10+10"
271
- end
272
-
273
- histogram
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"
274
264
  end
265
+
266
+ histogram
267
+ end
275
268
  end
276
269
  end
277
270
 
@@ -292,13 +285,11 @@ end
292
285
 
293
286
  # Only process first frame if multi-frame image
294
287
  image = Magick::Image.read(filename)
295
- if image.length > 1
296
- puts 'Charting 1st image'
297
- end
288
+ puts 'Charting 1st image' if image.length > 1
298
289
  image = image.first
299
290
 
300
291
  # Give the user something to look at while we're working.
301
- name = File.basename(filename).sub(/\..*?$/,'')
292
+ name = File.basename(filename).sub(/\..*?$/, '')
302
293
  $defout.sync = true
303
294
  printf "Creating #{name}_Histogram.miff"
304
295