rmagick 1.7.1

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 (239) hide show
  1. data/ChangeLog +232 -0
  2. data/Makefile.in +28 -0
  3. data/README.html +404 -0
  4. data/README.txt +397 -0
  5. data/configure +8554 -0
  6. data/configure.ac +497 -0
  7. data/doc/comtasks.html +241 -0
  8. data/doc/constants.html +1195 -0
  9. data/doc/css/doc.css +299 -0
  10. data/doc/css/popup.css +34 -0
  11. data/doc/draw.html +3108 -0
  12. data/doc/ex/Adispatch.rb +43 -0
  13. data/doc/ex/Zconstitute.rb +9 -0
  14. data/doc/ex/adaptive_threshold.rb +19 -0
  15. data/doc/ex/add_noise.rb +18 -0
  16. data/doc/ex/affine.rb +48 -0
  17. data/doc/ex/affine_transform.rb +20 -0
  18. data/doc/ex/arc.rb +47 -0
  19. data/doc/ex/arcpath.rb +33 -0
  20. data/doc/ex/average.rb +15 -0
  21. data/doc/ex/axes.rb +64 -0
  22. data/doc/ex/bilevel_channel.rb +20 -0
  23. data/doc/ex/blur_image.rb +12 -0
  24. data/doc/ex/border.rb +10 -0
  25. data/doc/ex/bounding_box.rb +48 -0
  26. data/doc/ex/cbezier1.rb +40 -0
  27. data/doc/ex/cbezier2.rb +40 -0
  28. data/doc/ex/cbezier3.rb +40 -0
  29. data/doc/ex/cbezier4.rb +41 -0
  30. data/doc/ex/cbezier5.rb +41 -0
  31. data/doc/ex/cbezier6.rb +51 -0
  32. data/doc/ex/channel.rb +26 -0
  33. data/doc/ex/channel_threshold.rb +48 -0
  34. data/doc/ex/charcoal.rb +12 -0
  35. data/doc/ex/chop.rb +29 -0
  36. data/doc/ex/circle.rb +31 -0
  37. data/doc/ex/clip_path.rb +56 -0
  38. data/doc/ex/coalesce.rb +60 -0
  39. data/doc/ex/color_fill_to_border.rb +29 -0
  40. data/doc/ex/color_floodfill.rb +28 -0
  41. data/doc/ex/color_histogram.rb +60 -0
  42. data/doc/ex/color_reset.rb +11 -0
  43. data/doc/ex/colorize.rb +16 -0
  44. data/doc/ex/colors.rb +65 -0
  45. data/doc/ex/composite.rb +135 -0
  46. data/doc/ex/contrast.rb +37 -0
  47. data/doc/ex/crop.rb +31 -0
  48. data/doc/ex/crop_with_gravity.rb +46 -0
  49. data/doc/ex/cycle_colormap.rb +21 -0
  50. data/doc/ex/demo.rb +324 -0
  51. data/doc/ex/drawcomp.rb +42 -0
  52. data/doc/ex/drop_shadow.rb +60 -0
  53. data/doc/ex/edge.rb +11 -0
  54. data/doc/ex/ellipse.rb +43 -0
  55. data/doc/ex/emboss.rb +11 -0
  56. data/doc/ex/enhance.rb +28 -0
  57. data/doc/ex/equalize.rb +11 -0
  58. data/doc/ex/flatten_images.rb +38 -0
  59. data/doc/ex/flip.rb +11 -0
  60. data/doc/ex/flop.rb +11 -0
  61. data/doc/ex/fonts.rb +20 -0
  62. data/doc/ex/frame.rb +12 -0
  63. data/doc/ex/gaussian_blur.rb +11 -0
  64. data/doc/ex/get_multiline_type_metrics.rb +53 -0
  65. data/doc/ex/get_pixels.rb +48 -0
  66. data/doc/ex/get_type_metrics.rb +140 -0
  67. data/doc/ex/gradientfill.rb +27 -0
  68. data/doc/ex/grav.rb +44 -0
  69. data/doc/ex/gravity.rb +80 -0
  70. data/doc/ex/hatchfill.rb +27 -0
  71. data/doc/ex/images/Ballerina.jpg +0 -0
  72. data/doc/ex/images/Ballerina3.jpg +0 -0
  73. data/doc/ex/images/Button_0.gif +0 -0
  74. data/doc/ex/images/Button_1.gif +0 -0
  75. data/doc/ex/images/Button_2.gif +0 -0
  76. data/doc/ex/images/Button_3.gif +0 -0
  77. data/doc/ex/images/Button_4.gif +0 -0
  78. data/doc/ex/images/Button_5.gif +0 -0
  79. data/doc/ex/images/Button_6.gif +0 -0
  80. data/doc/ex/images/Button_7.gif +0 -0
  81. data/doc/ex/images/Button_8.gif +0 -0
  82. data/doc/ex/images/Button_9.gif +0 -0
  83. data/doc/ex/images/Button_A.gif +0 -0
  84. data/doc/ex/images/Button_B.gif +0 -0
  85. data/doc/ex/images/Button_C.gif +0 -0
  86. data/doc/ex/images/Button_D.gif +0 -0
  87. data/doc/ex/images/Button_E.gif +0 -0
  88. data/doc/ex/images/Button_F.gif +0 -0
  89. data/doc/ex/images/Button_G.gif +0 -0
  90. data/doc/ex/images/Button_H.gif +0 -0
  91. data/doc/ex/images/Button_I.gif +0 -0
  92. data/doc/ex/images/Button_J.gif +0 -0
  93. data/doc/ex/images/Button_K.gif +0 -0
  94. data/doc/ex/images/Button_L.gif +0 -0
  95. data/doc/ex/images/Button_M.gif +0 -0
  96. data/doc/ex/images/Button_N.gif +0 -0
  97. data/doc/ex/images/Button_O.gif +0 -0
  98. data/doc/ex/images/Button_P.gif +0 -0
  99. data/doc/ex/images/Button_Q.gif +0 -0
  100. data/doc/ex/images/Button_R.gif +0 -0
  101. data/doc/ex/images/Button_S.gif +0 -0
  102. data/doc/ex/images/Button_T.gif +0 -0
  103. data/doc/ex/images/Button_U.gif +0 -0
  104. data/doc/ex/images/Button_V.gif +0 -0
  105. data/doc/ex/images/Button_W.gif +0 -0
  106. data/doc/ex/images/Button_X.gif +0 -0
  107. data/doc/ex/images/Button_Y.gif +0 -0
  108. data/doc/ex/images/Button_Z.gif +0 -0
  109. data/doc/ex/images/Cheetah.jpg +0 -0
  110. data/doc/ex/images/Coffee.wmf +0 -0
  111. data/doc/ex/images/Flower_Hat.jpg +0 -0
  112. data/doc/ex/images/Gold_Statue.jpg +0 -0
  113. data/doc/ex/images/Hot_Air_Balloons.jpg +0 -0
  114. data/doc/ex/images/Hot_Air_Balloons_H.jpg +0 -0
  115. data/doc/ex/images/No.wmf +0 -0
  116. data/doc/ex/images/Polynesia.jpg +0 -0
  117. data/doc/ex/images/Red_Rocks.jpg +0 -0
  118. data/doc/ex/images/Shorts.jpg +0 -0
  119. data/doc/ex/images/Snake.wmf +0 -0
  120. data/doc/ex/images/Violin.jpg +0 -0
  121. data/doc/ex/images/graydient230x6.gif +0 -0
  122. data/doc/ex/images/logo400x83.gif +0 -0
  123. data/doc/ex/images/model.miff +0 -0
  124. data/doc/ex/images/notimplemented.gif +0 -0
  125. data/doc/ex/images/smile.miff +0 -0
  126. data/doc/ex/images/spin.gif +0 -0
  127. data/doc/ex/implode.rb +32 -0
  128. data/doc/ex/level.rb +12 -0
  129. data/doc/ex/level_channel.rb +33 -0
  130. data/doc/ex/line.rb +40 -0
  131. data/doc/ex/map.rb +28 -0
  132. data/doc/ex/map_f.rb +15 -0
  133. data/doc/ex/matte_fill_to_border.rb +42 -0
  134. data/doc/ex/matte_floodfill.rb +35 -0
  135. data/doc/ex/matte_replace.rb +42 -0
  136. data/doc/ex/median_filter.rb +28 -0
  137. data/doc/ex/modulate.rb +11 -0
  138. data/doc/ex/mono.rb +23 -0
  139. data/doc/ex/morph.rb +26 -0
  140. data/doc/ex/mosaic.rb +35 -0
  141. data/doc/ex/motion_blur.rb +11 -0
  142. data/doc/ex/negate.rb +11 -0
  143. data/doc/ex/negate_channel.rb +19 -0
  144. data/doc/ex/normalize.rb +11 -0
  145. data/doc/ex/oil_paint.rb +11 -0
  146. data/doc/ex/opacity.rb +38 -0
  147. data/doc/ex/opaque.rb +14 -0
  148. data/doc/ex/ordered_dither.rb +11 -0
  149. data/doc/ex/path.rb +62 -0
  150. data/doc/ex/pattern1.rb +25 -0
  151. data/doc/ex/pattern2.rb +26 -0
  152. data/doc/ex/polygon.rb +24 -0
  153. data/doc/ex/polyline.rb +23 -0
  154. data/doc/ex/posterize.rb +19 -0
  155. data/doc/ex/preview.rb +16 -0
  156. data/doc/ex/qbezierpath.rb +49 -0
  157. data/doc/ex/quantize-m.rb +25 -0
  158. data/doc/ex/radial_blur.rb +19 -0
  159. data/doc/ex/raise.rb +11 -0
  160. data/doc/ex/random_channel_threshold.rb +17 -0
  161. data/doc/ex/random_threshold_channel.rb +18 -0
  162. data/doc/ex/rectangle.rb +33 -0
  163. data/doc/ex/reduce_noise.rb +28 -0
  164. data/doc/ex/roll.rb +9 -0
  165. data/doc/ex/rotate.rb +43 -0
  166. data/doc/ex/rotate_f.rb +14 -0
  167. data/doc/ex/roundrect.rb +32 -0
  168. data/doc/ex/rubyname.rb +31 -0
  169. data/doc/ex/segment.rb +11 -0
  170. data/doc/ex/shade.rb +11 -0
  171. data/doc/ex/shave.rb +15 -0
  172. data/doc/ex/shear.rb +10 -0
  173. data/doc/ex/skewx.rb +50 -0
  174. data/doc/ex/skewy.rb +45 -0
  175. data/doc/ex/smile.rb +124 -0
  176. data/doc/ex/solarize.rb +11 -0
  177. data/doc/ex/splice.rb +16 -0
  178. data/doc/ex/spread.rb +11 -0
  179. data/doc/ex/stegano.rb +50 -0
  180. data/doc/ex/stroke_dasharray.rb +41 -0
  181. data/doc/ex/stroke_linecap.rb +44 -0
  182. data/doc/ex/stroke_linejoin.rb +48 -0
  183. data/doc/ex/stroke_width.rb +47 -0
  184. data/doc/ex/swirl.rb +17 -0
  185. data/doc/ex/text.rb +32 -0
  186. data/doc/ex/text_align.rb +36 -0
  187. data/doc/ex/text_antialias.rb +33 -0
  188. data/doc/ex/text_undercolor.rb +26 -0
  189. data/doc/ex/texture_fill_to_border.rb +34 -0
  190. data/doc/ex/texture_floodfill.rb +31 -0
  191. data/doc/ex/texturefill.rb +25 -0
  192. data/doc/ex/threshold.rb +13 -0
  193. data/doc/ex/to_blob.rb +14 -0
  194. data/doc/ex/translate.rb +37 -0
  195. data/doc/ex/transparent.rb +38 -0
  196. data/doc/ex/trim.rb +25 -0
  197. data/doc/ex/unsharp_mask.rb +28 -0
  198. data/doc/ex/viewex.rb +36 -0
  199. data/doc/ex/wave.rb +9 -0
  200. data/doc/ilist.html +1592 -0
  201. data/doc/image1.html +3009 -0
  202. data/doc/image2.html +2169 -0
  203. data/doc/image3.html +2815 -0
  204. data/doc/imageattrs.html +1319 -0
  205. data/doc/imusage.html +403 -0
  206. data/doc/index.html +418 -0
  207. data/doc/info.html +949 -0
  208. data/doc/magick.html +439 -0
  209. data/doc/scripts/doc.js +9 -0
  210. data/doc/struct.html +1334 -0
  211. data/doc/usage.html +1318 -0
  212. data/examples/describe.rb +44 -0
  213. data/examples/histogram.rb +289 -0
  214. data/examples/image_opacity.rb +29 -0
  215. data/examples/import_export.rb +31 -0
  216. data/examples/pattern_fill.rb +38 -0
  217. data/examples/rotating_text.rb +47 -0
  218. data/examples/thumbnail.rb +65 -0
  219. data/examples/vignette.rb +79 -0
  220. data/ext/RMagick/MANIFEST +239 -0
  221. data/ext/RMagick/extconf.rb.in +21 -0
  222. data/ext/RMagick/rmagick.h +938 -0
  223. data/ext/RMagick/rmagick_config.h.in +170 -0
  224. data/ext/RMagick/rmdraw.c +1308 -0
  225. data/ext/RMagick/rmfill.c +609 -0
  226. data/ext/RMagick/rmilist.c +685 -0
  227. data/ext/RMagick/rmimage.c +7980 -0
  228. data/ext/RMagick/rminfo.c +982 -0
  229. data/ext/RMagick/rmmain.c +1497 -0
  230. data/ext/RMagick/rmutil.c +2685 -0
  231. data/install.rb +1015 -0
  232. data/lib/RMagick.rb +1486 -0
  233. data/metaconfig.in +6 -0
  234. data/post-clean.rb +12 -0
  235. data/post-install.rb +36 -0
  236. data/post-setup.rb +245 -0
  237. data/rmagick.gemspec +22 -0
  238. data/uninstall.rb +71 -0
  239. metadata +286 -0
data/doc/usage.html ADDED
@@ -0,0 +1,1318 @@
1
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
2
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
3
+
4
+ <html xmlns="http://www.w3.org/1999/xhtml">
5
+ <head>
6
+ <meta name="generator" content=
7
+ "HTML Tidy for Linux/x86 (vers 1st September 2004), see www.w3.org" />
8
+
9
+ <title>RMagick: How to use RMagick</title>
10
+ <meta http-equiv="Content-Type" content=
11
+ "text/html; charset=us-ascii" />
12
+ <meta name="GENERATOR" content="Quanta Plus" />
13
+ <meta name="Copyright" content=
14
+ "Copyright (C) 2004 by Timothy P. Hunter" />
15
+ <link rel="stylesheet" type="text/css" href="css/doc.css" />
16
+ <script type="text/javascript" src="scripts/doc.js">
17
+ </script>
18
+ <style type="text/css">
19
+ /*<![CDATA[*/
20
+
21
+ /* Styles local to this page. */
22
+
23
+ #index {
24
+ margin-left: 100px;
25
+ margin-right: 100px;
26
+ }
27
+ #index h4 {
28
+ position: relative;
29
+ left: -100px;
30
+ padding-left: 5px;
31
+ background-image: url(graydient210x6.gif);
32
+ background-repeat: repeat-y;
33
+ color: black;
34
+ }
35
+
36
+ /*
37
+ * The "ilist" class identifies ImageList methods in the index.
38
+ */
39
+ .ilist {
40
+ font-weight: bold;
41
+ }
42
+ .ilist a:link {
43
+ font-weight: bold;
44
+ text-decoration: none;
45
+ }
46
+ .ilist a:visited {
47
+ font-weight: bold;
48
+ color: #7f7fff;
49
+ }
50
+ .ilist a:hover {
51
+ text-decoration: underline;
52
+ }
53
+ .ilist a:active {
54
+ background-color: blue;
55
+ color: white;
56
+ text-decoration: underline;
57
+ }
58
+
59
+ #axes {
60
+ margin-left:100px;
61
+ margin-right:100px;
62
+ margin-bottom: 1em;
63
+ position:relative;
64
+ }
65
+ #axes div {
66
+ position:absolute;
67
+ top:0;
68
+ left: 260px;
69
+ }
70
+ #rubyname {
71
+ margin-left: auto;
72
+ margin-right:auto;
73
+ width:300px;
74
+ margin-bottom:1em;
75
+ }
76
+ #footnotes {
77
+ border-top: thin solid black;
78
+ padding-top: 1em;????
79
+ }
80
+ #footnotes h5 {
81
+ display: none;
82
+ }
83
+
84
+ /*]]>*/
85
+ </style>
86
+ </head>
87
+
88
+ <body>
89
+ <h6 id="header">RMagick User's Guide and Reference</h6>
90
+
91
+ <div class="nav">
92
+ &laquo;&nbsp;<a href="index.html">Prev</a> | <a href=
93
+ "index.html">Contents</a> | <a href=
94
+ "imusage.html">Next</a>&nbsp;&raquo;
95
+ </div>
96
+
97
+ <h1>How to use RMagick</h1>
98
+
99
+ <div id="toc">
100
+ <h2>Table of Contents</h2>
101
+
102
+ <ul style="margin-left: 15px; padding-top: 1em">
103
+ <li><a href="#basics">Basic concepts</a></li>
104
+
105
+ <li><a href="#reading">Reading, writing, and creating
106
+ images</a></li>
107
+
108
+ <li><a href="#displaying">Displaying images</a></li>
109
+
110
+ <li><a href="#modifying">Examining and modifying
111
+ images</a></li>
112
+
113
+ <li><a href="#marshaling">Marshaling images</a></li>
114
+
115
+ <li><a href="#drawing_on">Drawing on and adding text to
116
+ images</a></li>
117
+
118
+ <li><a href="#more">Where to go from here</a></li>
119
+ </ul>
120
+ </div>
121
+
122
+ <h2 id="basics">Basic concepts</h2>
123
+
124
+ <p>Let's look at the RMagick equivalent of "Hello, world". This
125
+ program reads an image file named "Cheetah.jpg" and
126
+ displays<sup><a href="#display">1</a></sup> it on your
127
+ monitor.</p>
128
+ <pre class="example">
129
+ 1. require 'RMagick'
130
+ 2. include Magick
131
+ 3.
132
+ 4. cat = ImageList.new("Cheetah.jpg")
133
+ 5. cat.display
134
+ 6. exit
135
+
136
+ </pre>
137
+
138
+ <p class="example_cutline">MS Windows users note: The <span
139
+ style="font-style:normal">display</span> method does not work
140
+ on native MS Windows. You must use an external viewer to view
141
+ the images you create.</p>
142
+
143
+ <p>Line 1 requires the RMagick.rb file, which defines the
144
+ <b>Magick</b> module. The Magick module contains 3 major classes,
145
+ <b>ImageList</b>, <b>Image</b>, and <b>Draw</b>. This section -
146
+ <em>Basic Comcepts</em> - describes the ImageList and Image
147
+ classes. The Draw class is explained in the <em><a href=
148
+ "#drawing">Drawing on and adding text to images</a></em> section,
149
+ below.</p>
150
+
151
+ <p>The statement on line 5 creates an <em>imagelist</em> object
152
+ and initializes it by reading the <code>Cheetah.jpg</code> file
153
+ in the current directory. Line 6 sends the <code>display</code>
154
+ method to the object. When you send <code>display</code> to an
155
+ imagelist, it causes all the images in the imagelist to be
156
+ displayed on the default X Window screen. In this case, the
157
+ <code>display</code> method makes a picture of a cheetah appear
158
+ on your monitor.</p>
159
+
160
+ <p>Type this program in and try running it now. The
161
+ <code>Cheetah.jpg</code> file is in the <code>ex/images</code>
162
+ subdirectory where you installed the RMagick documentation.</p>
163
+
164
+ <p>The Image and ImageList classes are closely related. An
165
+ <em>Image</em> object describes one image or one frame in an
166
+ image with multiple frames. (An animated GIF or a Photoshop image
167
+ with multiple layers are examples of images with multiple
168
+ frames.) You can create a image object from an image file such as
169
+ a GIF, PNG, or JPEG. You can create a image from scratch by
170
+ specifying its dimensions. You can write an image to disk,
171
+ display it on a screen, change its size or orientation, convert
172
+ it to another format, or otherwise modify it using one of over
173
+ 100 methods.</p>
174
+
175
+ <p>An <em>ImageList</em> object is a <em>list</em> of images. It
176
+ contains zero or more images and a <em>scene number</em>. The
177
+ scene number indicates the <em>current image</em>. The ImageList
178
+ class includes methods that operate on all the images in the
179
+ list. Also, with a very few exceptions, any method defined in the
180
+ Image class can be used as well. Since Image methods always
181
+ operate on a single image, when an Image method is sent to an
182
+ imagelist, the ImageList class sends the method to the current
183
+ image, that is, the image specified by the scene number.</p>
184
+
185
+ <p>The ImageList class is a subclass of the Array class, so you
186
+ can use most Array methods to change the images in the imagelist.
187
+ For example, you can use the <code>&lt;&lt;</code> method to add
188
+ an image to the list.</p>
189
+
190
+ <p>Going back to the example, let's make one modification.</p>
191
+ <pre class="example">
192
+ 1. require 'RMagick'
193
+ 2. include Magick
194
+ 3.
195
+ 4. cat = ImageList.new("Cheetah.jpg")
196
+ 5. smallcat = cat.minify
197
+ 6. smallcat.display
198
+ 7. exit
199
+ </pre>
200
+
201
+ <p>The difference is the statement on line 5. This statement
202
+ sends the <code>minify</code> method to the imagelist. The
203
+ <code>minify</code> method is an Image method that reduces the
204
+ size of an image to half its original size. Remember, since
205
+ <code>minify</code> is an Image method, the ImageList class sends
206
+ <code>minify</code> to the current (and only) image. The return
207
+ value is a new image, half the size of the original.</p>
208
+
209
+ <p>Line 6 demonstrates the Image class's <code>display</code>
210
+ method, which displays a single image on the X Window screen.
211
+ <code>Image#display</code> makes a picture of a (in this case,
212
+ small) cheetah appear on your monitor.</p>
213
+
214
+ <p>Here's how to write the small cheetah to a file in GIF
215
+ format.</p>
216
+ <pre class="example">
217
+ 1. require 'RMagick'
218
+ 2. include Magick
219
+ 3.
220
+ 4. cat = ImageList.new("Cheetah.jpg")
221
+ 5. smallcat = cat.minify
222
+ 6. smallcat.display
223
+ 7. smallcat.write("Small-Cheetah.gif")
224
+ 8. exit
225
+ </pre>
226
+
227
+ <p>The statement on line 7 writes the image to a file. Notice
228
+ that the filename extension is <code>gif</code>. When writing
229
+ images, &times;Magick uses the filename extension to determine
230
+ what image format to write. In this example, the
231
+ <code>Small-Cheetah.gif</code> file will be in the GIF format.
232
+ Notice how easy it is to covert an image from one format to
233
+ another? (For more details, see <a href=
234
+ "imusage.html#formats">Image formats and filenames</a>.)</p>
235
+
236
+ <p>So why, in the previous example, did I create <code>cat</code>
237
+ as an ImageList object containing just one image, instead of
238
+ creating an Image object? No reason, really. When you only have
239
+ one image to deal with, imagelists and images are pretty much
240
+ interchangeable.</p>
241
+
242
+ <p><em><b>Note:</b></em> In most cases, an Image method does not
243
+ modify the image to which it is sent. Instead, the method returns
244
+ a new image, suitably modified. For example, the <a href=
245
+ "image3.html#resize"><code>resize</code></a> method returns a new
246
+ image, sized as specified. The receiver image is unaltered.
247
+ (Following the Ruby convention, when a method alters the receiver
248
+ object, the method name ends with "!". For example, the <a href=
249
+ "image3.html#resize_bang"><code>resize!</code></a> method resizes
250
+ the receiver in place.)</p>
251
+
252
+ <h2 id="reading">Reading, writing, and creating images</h2>
253
+
254
+ <p>You've already seen that you can create an imagelist and
255
+ initialize it by specifying the name of an image file as the
256
+ argument to <a href=
257
+ "ilist.html#new"><code>ImageList.new</code></a>. In fact,
258
+ <code>new</code> can take any number of file name arguments. If
259
+ the file contains a single image, <code>new</code> reads the
260
+ file, creates an image, and adds it to the imagelist. If the file
261
+ is a multi-frame image file, <code>new</code> adds an image for
262
+ each frame or layer in the file. Lastly, <code>new</code> changes
263
+ the scene number to point to the last image in the imagelist. In
264
+ the simple case, <code>new</code> reads a single image from a
265
+ file and sets the scene number to 0.</p>
266
+
267
+ <p>You can also create an image from scratch by calling <a href=
268
+ "image1.html#new"><code>Image.new</code></a>. This method takes 2
269
+ or 3 arguments. The first argument is the number of columns in
270
+ the new image (its width). The second argument is the number of
271
+ rows (its height). If present, the 3rd argument is a <a href=
272
+ "struct.html#fill"><code>Fill</code></a> object. To add a
273
+ "scratch" image to an imagelist, call <a href=
274
+ "ilist.html#new_image"><code>ImageList#new_image</code></a>. This
275
+ method calls <code>Image.new</code>, adds the new image to the
276
+ imagelist, and sets the scene number to point to the new image.
277
+ Scratch images are good for <a href="#drawing">drawing</a> on or
278
+ creating images by <a href=
279
+ "image1.html#composite">compositing</a>.</p>
280
+
281
+ <p>Like many other methods in the Image and ImageList classes,
282
+ <code>Image.new</code> accepts an optional block that can be used
283
+ to set additional optional parameters. If the block is present,
284
+ <code>Image.new</code> creates a <a href="info.html">parameter
285
+ object</a> and yields to the block in the scope of that object.
286
+ You set the parameters by calling attribute setter methods
287
+ defined in the parameter object's class. For example, you can set
288
+ the background color of a new image to red with the
289
+ <code>background_color=</code> method, as shown here:</p>
290
+ <pre class="example">
291
+ require 'RMagick'
292
+ include Magick
293
+ # Create a 100x100 red image.
294
+ f = Image.new(100,100) { self.background_color = "red" }
295
+ f.display
296
+ exit
297
+ </pre>
298
+
299
+ <p>Within the parameter block you must use <code>self</code> so
300
+ that Ruby can knows that this statement is a method call, not an
301
+ assignment to a variable.</p>
302
+
303
+ <p>You can create an image by capturing it from the XWindow
304
+ screen using <a href=
305
+ "image1.html#capture"><code>Image.capture</code></a>. This method
306
+ can capture the root window, a window identified by name or ID
307
+ number, or perform an interactive capture whereby you designate
308
+ the desired window by clicking it or by drawing a rectangle on
309
+ the screen with your mouse.</p>
310
+
311
+ <p>Both the Image class and the ImageList class have
312
+ <code>write</code> methods. Both accept a single argument, the
313
+ name of the file to be written. <a href=
314
+ "image3.html#write"><code>Image#write</code></a> simply writes
315
+ the image to a file. Like the <code>Image#read</code> method,
316
+ <code>write</code> yields to an optional block that you can use
317
+ to set parameters that control how the image is written.</p>
318
+
319
+ <p>If an ImageList object contains only one image, then <a href=
320
+ "ilist.html#write"><code>ImageList#write</code></a> is the same
321
+ as <code>Image#write</code>. However, if the imagelist contains
322
+ multiple images and the file format (determined by the file name
323
+ extension, as I mentioned earlier) supports multi-frame images,
324
+ <code>Image#write</code> will automatically create a multi-frame
325
+ image file.</p>
326
+
327
+ <p>For example, the following program reads three GIF files and
328
+ then uses <code>ImageList#write</code> to combine all the images
329
+ in those files (remember, each input file can contain multiple
330
+ images) into one animated GIF file.</p>
331
+ <pre class="example">
332
+ #! /usr/local/bin/ruby -w
333
+ require 'RMagick'
334
+ anim = ImageList.new("start.gif", "middle.gif", "finish.gif")
335
+ anim.write("animated.gif")
336
+ exit
337
+ </pre>
338
+
339
+ <h2 id="displaying">Displaying images</h2>
340
+
341
+ <p>RMagick defines 3 methods for displaying images and
342
+ imagelists. Both the Image class and the ImageList class have a
343
+ <code>display</code> method. The <a href=
344
+ "image1.html#display"><code>Image#display</code></a> method
345
+ displays the image on the default X Window screen. For imagelists
346
+ with just one image, <a href=
347
+ "ilist.html#display"><code>ImageList#display</code></a> is
348
+ identical to <code>Image#display</code>. However, if the
349
+ imagelist contains multiple images,
350
+ <code>ImageList#display</code> displays each of the images in
351
+ turn. With both methods, right-clicking the display window will
352
+ produce a menu of other options.</p>
353
+
354
+ <p>The <a href=
355
+ "ilist.html#animate"><code>ImageList#animate</code></a> method
356
+ repeatedly cycles through all the images in an imagelist,
357
+ displaying each one in turn. You can control the speed of the
358
+ animation with the <a href=
359
+ "ilist.html#delay_eq"><code>ImageList#delay=</code></a>
360
+ method.</p>
361
+
362
+ <h2 id="modifying">Examining and modifying images</h2>
363
+
364
+ <p>Once you've created an image or imagelist, what can you do
365
+ with it? The Image and ImageList classes define over 100 methods
366
+ for examining and modifying images, both individually and in
367
+ groups. Remember, unless the ImageList class defines a method
368
+ with the same name, you can send any method defined in the Image
369
+ class to an instance of the ImageList class. The ImageList class
370
+ sends the method to the current image and returns the result.</p>
371
+
372
+ <p>The methods can be classified into the following broad groups.
373
+ ImageList method descriptions look like <span class=
374
+ "ilist">this</span>. Some of the listed methods are not available
375
+ in some releases of &times;Magick. See the method documentation
376
+ for details.</p>
377
+
378
+ <div id="index">
379
+ <h4>Utility methods</h4>
380
+
381
+ <dl>
382
+ <dt><a href="image1.html#spaceship">&lt;=&gt;</a></dt>
383
+
384
+ <dd>Compare 2 images</dd>
385
+
386
+ <dt class="ilist"><a href=
387
+ "ilist.html#spaceship">&lt;=&gt;</a></dt>
388
+
389
+ <dd class="ilist">Compare 2 imagelists</dd>
390
+
391
+ <dt><a href="image1.html#aref">[ ]</a></dt>
392
+
393
+ <dd>Reference an image property</dd>
394
+
395
+ <dt><a href="image1.html#aset">[ ]=</a></dt>
396
+
397
+ <dd>Set an image property</dd>
398
+
399
+ <dt><a href="image1.html#changed_q">changed?</a></dt>
400
+
401
+ <dd>Has the image been changed?</dd>
402
+
403
+ <dt><a href="image1.html#channel">channel</a></dt>
404
+
405
+ <dd>Extract a color channel from the image</dd>
406
+
407
+ <dt><a href=
408
+ "image1.html#compare_channel">compare_channel</a></dt>
409
+
410
+ <dd>Compare one or more channels between two images</dd>
411
+
412
+ <dt><a href=
413
+ "image1.html#channel_depth">channel_depth</a></dt>
414
+
415
+ <dd>Return the depth of the specified channel or
416
+ channels</dd>
417
+
418
+ <dt><a href=
419
+ "image1.html#channel_extrema">channel_extrema</a></dt>
420
+
421
+ <dd>Return the maximum and minimum intensity values for one
422
+ or more channels in the image</dd>
423
+
424
+ <dt><a href=
425
+ "image1.html#color_histogram">color_histogram</a></dt>
426
+
427
+ <dd>Count the number of times each unique color appears in
428
+ the image</dd>
429
+
430
+ <dt><a href="image1.html#copy">copy</a></dt>
431
+
432
+ <dd>Return a deep copy of the image</dd>
433
+
434
+ <dt class="ilist"><a href="ilist.html#copy">copy</a></dt>
435
+
436
+ <dd class="ilist">Return a deep copy of the imagelist</dd>
437
+
438
+ <dt><a href="image1.html#difference">difference</a></dt>
439
+
440
+ <dd>Compute the difference between two images</dd>
441
+
442
+ <dt><a href="image1.html#each_profile">each_profile</a></dt>
443
+
444
+ <dd>Iterate over all the profiles associated with the
445
+ image</dd>
446
+
447
+ <dt><a href=
448
+ "image2.html#export_pixels">export_pixels</a></dt>
449
+
450
+ <dd>Extract pixel data from the image into an array</dd>
451
+
452
+ <dt><a href=
453
+ "image2.html#get_exif_by_entry">get_exif_by_entry</a>,
454
+ <a href=
455
+ "image2.html#get_exif_by_number">get_exif_by_number</a></dt>
456
+
457
+ <dd>Get one or more EXIF property values for the image</dd>
458
+
459
+ <dt><a href="image2.html#get_pixels">get_pixels</a></dt>
460
+
461
+ <dd>Copy a region of pixels from the image</dd>
462
+
463
+ <dt><a href="image2.html#gray_q">gray?</a></dt>
464
+
465
+ <dd>Are all the pixels in the image gray?</dd>
466
+
467
+ <dt><a href=
468
+ "image2.html#import_pixels">import_pixels</a></dt>
469
+
470
+ <dd>Replace pixels in the image with pixel data from an
471
+ array</dd>
472
+
473
+ <dt><a href="image2.html#monochrome_q">monochrome?</a></dt>
474
+
475
+ <dd>Are all the pixels in the image either black or
476
+ white?</dd>
477
+
478
+ <dt><a href="image2.html#opaque_q">opaque?</a></dt>
479
+
480
+ <dd>Are all the pixels in the image opaque?</dd>
481
+
482
+ <dt><a href="image2.html#palette_q">palette?</a></dt>
483
+
484
+ <dd>Is the image a PseudoClass type image with 256 colors or
485
+ less?</dd>
486
+
487
+ <dt><a href="image3.html#preview">preview</a></dt>
488
+
489
+ <dd>Show the effect of a transformation method on the
490
+ image</dd>
491
+
492
+ <dt><a href="image3.html#profile_bang">profile!</a></dt>
493
+
494
+ <dd>Add or remove an ICM, IPTC, or generic profile from the
495
+ image</dd>
496
+
497
+ <dt><a href="image3.html#properties">properties</a></dt>
498
+
499
+ <dd>Iterate over all the properties associated with the
500
+ image</dd>
501
+
502
+ <dt><a href=
503
+ "image3.html#set_channel_depth">set_channel_depth</a></dt>
504
+
505
+ <dd>Set the specified channel's depth</dd>
506
+
507
+ <dt><a href="image3.html#signature">signature</a></dt>
508
+
509
+ <dd>Compute the 64-byte message signature for the image</dd>
510
+
511
+ <dt><a href="image3.html#statistics">statistics</a></dt>
512
+
513
+ <dd>Compute image statistics</dd>
514
+
515
+ <dt><a href="image3.html#store_pixels">store_pixels</a></dt>
516
+
517
+ <dd>Replace a region of pixels in the image</dd>
518
+
519
+ <dt><a href="image3.html#strip_bang">strip!</a></dt>
520
+
521
+ <dd>Strip the image of all comments and profiles</dd>
522
+
523
+ <dt><a href="image3.html#view">view</a></dt>
524
+
525
+ <dd>Access pixels by their coordinates.</dd>
526
+ </dl>
527
+
528
+ <h4>Reduce the number of colors</h4>
529
+
530
+ <dl>
531
+ <dt><a href=
532
+ "image1.html#compress_colormap_bang">compress_colormap!</a></dt>
533
+
534
+ <dd>Remove duplicate or unused entries in the image's
535
+ colormap</dd>
536
+
537
+ <dt><a href=
538
+ "image2.html#grayscale_pseudo_class">grayscale_pseudo_class</a></dt>
539
+
540
+ <dd>Convert the image to a grayscale PseudoClass image.</dd>
541
+
542
+ <dt><a href="image2.html#map">map</a></dt>
543
+
544
+ <dd>Replace the colors of the image with the nearest colors
545
+ from a reference image</dd>
546
+
547
+ <dt class="ilist"><a href="ilist.html#map">map</a></dt>
548
+
549
+ <dd class="ilist">Replace the colors of all the images in the
550
+ imagelist with the nearest colors from a reference image</dd>
551
+
552
+ <dt><a href=
553
+ "image2.html#ordered_dither">ordered_dither</a></dt>
554
+
555
+ <dd>Reduce the image to monochrome using the ordered dither
556
+ technique</dd>
557
+
558
+ <dt><a href="image2.html#posterize">posterize</a></dt>
559
+
560
+ <dd>Reduce the number of colors for a "poster" effect</dd>
561
+
562
+ <dt><a href="image3.html#quantize">quantize</a></dt>
563
+
564
+ <dd>Choose a fixed number of colors to represent the
565
+ image</dd>
566
+
567
+ <dt class="ilist"><a href=
568
+ "ilist.html#quantize">quantize</a></dt>
569
+
570
+ <dd class="ilist">Choose a fixed number of colors to
571
+ represent all the images in the imagelist</dd>
572
+ </dl>
573
+
574
+ <h4>Resize</h4>
575
+
576
+ <dl>
577
+ <dt><a href=
578
+ "image1.html#change_geometry">change_geometry</a></dt>
579
+
580
+ <dd>Compute a new constrained size for the image</dd>
581
+
582
+ <dt><a href="image2.html#magnify">magnify</a></dt>
583
+
584
+ <dd>Double the size of the image</dd>
585
+
586
+ <dt><a href="image2.html#minify">minify</a></dt>
587
+
588
+ <dd>Halve the size of the image</dd>
589
+
590
+ <dt><a href="image3.html#resize">resize</a></dt>
591
+
592
+ <dd>Resize the image using a filter</dd>
593
+
594
+ <dt><a href="image3.html#sample">sample</a></dt>
595
+
596
+ <dd>Resize the image using pixel sampling</dd>
597
+
598
+ <dt><a href="image3.html#scale">scale</a></dt>
599
+
600
+ <dd>Resize the image</dd>
601
+
602
+ <dt><a href="image3.html#thumbnail">thumbnail</a></dt>
603
+
604
+ <dd>Quickly create a thumbnail of the image</dd>
605
+ </dl>
606
+
607
+ <h4>Change colors or opacity</h4>
608
+
609
+ <dl>
610
+ <dt><a href=
611
+ "image1.html#color_fill_to_border">color_fill_to_border</a></dt>
612
+
613
+ <dd>Change the color of neighboring pixels. Stop at the
614
+ image's border color.</dd>
615
+
616
+ <dt><a href=
617
+ "image1.html#color_floodfill">color_floodfill</a></dt>
618
+
619
+ <dd>Change the color of neighboring pixels that are the same
620
+ color</dd>
621
+
622
+ <dt><a href="image1.html#colormap">colormap</a></dt>
623
+
624
+ <dd>Get or set a color in the image's colormap</dd>
625
+
626
+ <dt><a href="image1.htlm#color_point">color_point</a></dt>
627
+
628
+ <dd>Change the color of a single pixel in the image</dd>
629
+
630
+ <dt><a href=
631
+ "image1.html#color_reset_bang">color_reset!</a></dt>
632
+
633
+ <dd>Set the entire image to a single color</dd>
634
+
635
+ <dt><a href=
636
+ "image1.html#cycle_colormap">cycle_colormap</a></dt>
637
+
638
+ <dd>Displace the image's colormap</dd>
639
+
640
+ <dt><a href="image1.html#erase_bang">erase!</a></dt>
641
+
642
+ <dd>Set the entire image to a single color</dd>
643
+
644
+ <dt><a href=
645
+ "image2.html#matte_fill_to_border">matte_fill_to_border</a></dt>
646
+
647
+ <dd>Make transparent neighboring pixels. Stop at the image's
648
+ border color.</dd>
649
+
650
+ <dt><a href=
651
+ "image2.html#matte_floodfill">matte_floodfill</a></dt>
652
+
653
+ <dd>Make transparent neighboring pixels that are the same
654
+ color</dd>
655
+
656
+ <dt><a href="image2.html#matte_point">matte_point</a></dt>
657
+
658
+ <dd>Make a single pixel transparent</dd>
659
+
660
+ <dt><a href=
661
+ "image2.html#matte_reset_bang">matte_reset!</a></dt>
662
+
663
+ <dd>Make the entire image transparent</dd>
664
+
665
+ <dt><a href="image2.html#opaque">opaque</a></dt>
666
+
667
+ <dd>Change all pixels from the specified color to a new
668
+ color</dd>
669
+
670
+ <dt><a href="image2.html#pixel_color">pixel_color</a></dt>
671
+
672
+ <dd>Get or set the color of a single pixel</dd>
673
+
674
+ <dt><a href="image3.html#splice">splice</a></dt>
675
+
676
+ <dd>Splice a solid color into the image.</dd>
677
+
678
+ <dt><a href=
679
+ "image3.html#texture_fill_to_border">texture_fill_to_border</a></dt>
680
+
681
+ <dd>Replace neighbor pixels with pixels from a texture image.
682
+ Stop at the image's border color.</dd>
683
+
684
+ <dt><a href=
685
+ "image3.html#texture_floodfill">texture_floodfill</a></dt>
686
+
687
+ <dd>Replace neighboring pixels that are the same color with
688
+ pixels from a texture image</dd>
689
+
690
+ <dt><a href="image3.html#transparent">transparent</a></dt>
691
+
692
+ <dd>Change the opacity value of pixels having the specified
693
+ color</dd>
694
+ </dl>
695
+
696
+ <h4>Rotate or shear</h4>
697
+
698
+ <dl>
699
+ <dt><a href=
700
+ "image1.html#affine_transform">affine_transform</a></dt>
701
+
702
+ <dd>Transform the image as dictated by an affine matrix</dd>
703
+
704
+ <dt><a href="image3.html#rotate">rotate</a></dt>
705
+
706
+ <dd>Rotate the image by the specified angle</dd>
707
+
708
+ <dt><a href="image3.html#shear">shear</a></dt>
709
+
710
+ <dd>Shear the image along the X or Y axis, creating a
711
+ parallelogram</dd>
712
+ </dl>
713
+
714
+ <h4>Transform</h4>
715
+
716
+ <dl>
717
+ <dt class="ilist"><a href="ilist.html#append">append</a></dt>
718
+
719
+ <dd class="ilist">Append all the images in the imagelist into
720
+ a single image</dd>
721
+
722
+ <dt class="ilist"><a href=
723
+ "ilist.html#average">average</a></dt>
724
+
725
+ <dd class="ilist">Average all the images in the imagelist
726
+ into a single image</dd>
727
+
728
+ <dt><a href="image1.html#chop">chop</a></dt>
729
+
730
+ <dd>Chop a region from the image</dd>
731
+
732
+ <dt class="ilist"><a href=
733
+ "ilist.html#coalesce">coalesce</a></dt>
734
+
735
+ <dd class="ilist">Merge successive images in the imagelist
736
+ into a new imagelist</dd>
737
+
738
+ <dt><a href="image1.html#composite">composite</a></dt>
739
+
740
+ <dd>Composite the image onto another image</dd>
741
+
742
+ <dt><a href=
743
+ "image1.html#composite_affine">composite_affine</a></dt>
744
+
745
+ <dd>Composite the image onto another image as dictated by an
746
+ affine matrix</dd>
747
+
748
+ <dt><a href="image1.html#crop">crop</a></dt>
749
+
750
+ <dd>Extract a region from the image</dd>
751
+
752
+ <dt class="ilist"><a href=
753
+ "ilist.html#deconstruct">deconstruct</a></dt>
754
+
755
+ <dd class="ilist">Return the bounding region of the
756
+ differences between the images in the imagelist</dd>
757
+
758
+ <dt class="ilist"><a href=
759
+ "ilist.html#flatten_images">flatten_images</a></dt>
760
+
761
+ <dd class="ilist">Merge all the images in the imagelist into
762
+ a single image</dd>
763
+
764
+ <dt><a href="image2.html#flip">flip</a></dt>
765
+
766
+ <dd>Create a vertical mirror image</dd>
767
+
768
+ <dt><a href="image2.html#flop">flop</a></dt>
769
+
770
+ <dd>Create a horizontal mirror image</dd>
771
+
772
+ <dt class="ilist"><a href="ilist.html#mosaic">mosaic</a></dt>
773
+
774
+ <dd class="ilist">Inlay all the images in the imagelist into
775
+ a single image</dd>
776
+
777
+ <dt><a href="image3.html#roll">roll</a></dt>
778
+
779
+ <dd>Offset the image</dd>
780
+
781
+ <dt><a href="image3.html#shave">shave</a></dt>
782
+
783
+ <dd>Shave regions from the edges of the image</dd>
784
+
785
+ <dt><a href="image3.html#trim">trim</a></dt>
786
+
787
+ <dd>Remove borders from the edges of the image</dd>
788
+ </dl>
789
+
790
+ <h4>Enhance</h4>
791
+
792
+ <dl>
793
+ <dt><a href="image1.html#contrast">contrast</a></dt>
794
+
795
+ <dd>Enhance the intensity differences between the lighter and
796
+ darker elements in the image</dd>
797
+
798
+ <dt><a href="image1.html#despeckle">despeckle</a></dt>
799
+
800
+ <dd>Reduce the speckle noise in the image</dd>
801
+
802
+ <dt><a href="image2.html#enhance">enhance</a></dt>
803
+
804
+ <dd>Apply a digital filter that improves the quality of a
805
+ noisy image</dd>
806
+
807
+ <dt><a href="image2.html#equalize">equalize</a></dt>
808
+
809
+ <dd>Apply a histogram equalization to the image</dd>
810
+
811
+ <dt><a href="image2.html#gamma_correct">gamma_correct</a>,
812
+ <a href="image2.html#gamma_channel">gamma_channel</a></dt>
813
+
814
+ <dd>Gamma correct the image</dd>
815
+
816
+ <dt><a href="image2.html#level">level</a></dt>
817
+
818
+ <dd>Adjust the levels of the image</dd>
819
+
820
+ <dt><a href=
821
+ "image2.html#level_channel">level_channel</a></dt>
822
+
823
+ <dd>Adjust the levels of one or more channels in the
824
+ image</dd>
825
+
826
+ <dt><a href=
827
+ "image2.html#median_filter">median_filter</a></dt>
828
+
829
+ <dd>Apply a digital filter that improves the quality of a
830
+ noisy image</dd>
831
+
832
+ <dt><a href="image2.html#modulate">modulate</a></dt>
833
+
834
+ <dd>Change the brightness, saturation, or hue of the
835
+ image</dd>
836
+
837
+ <dt><a href="image2.html#negate">negate</a>, <a href=
838
+ "image2.html#negate_channel">negate_channel</a></dt>
839
+
840
+ <dd>Negate the colors of the image</dd>
841
+
842
+ <dt><a href="image2.html#normalize">normalize</a>, <a href=
843
+ "image2.html#normalize_channel">normalize_channel</a></dt>
844
+
845
+ <dd>Enhance the contrast of the image</dd>
846
+
847
+ <dt><a href=
848
+ "image3.html#random_threshold_channel">random_threshold_channel</a></dt>
849
+
850
+ <dd>Change the value of individual pixels based on the
851
+ intensity of each pixel compared to a random threshold.</dd>
852
+
853
+ <dt><a href="image3.html#reduce_noise">reduce_noise</a></dt>
854
+
855
+ <dd>Smooth the contours of an image while still preserving
856
+ edge information</dd>
857
+
858
+ <dt><a href="image3.html#sharpen">sharpen</a>, <a href=
859
+ "image3.html#sharpen_channel">sharpen_channel</a>, <a href=
860
+ "image3.html#unsharp_mask">unsharp_mask</a>, <a href=
861
+ "image3.html#unsharp_mask_channel">unsharp_mask_channel</a></dt>
862
+
863
+ <dd>Sharpen the image</dd>
864
+ </dl>
865
+
866
+ <h4>Add effects</h4>
867
+
868
+ <dl>
869
+ <dt><a href=
870
+ "image1.html#adaptive_threshold">adaptive_threshold</a></dt>
871
+
872
+ <dd>Threshold an image whose global intensity histogram
873
+ doesn't contain distinctive peaks</dd>
874
+
875
+ <dt><a href="image1.html#add_noise">add_noise</a></dt>
876
+
877
+ <dd>Add random noise</dd>
878
+
879
+ <dt><a href=
880
+ "image1.html#bilevel_channel">bilevel_channel</a></dt>
881
+
882
+ <dd class="imquote">Change the value of individual image
883
+ pixels based on the intensity of each pixel channel</dd>
884
+
885
+ <dt><a href=
886
+ "image1.html#black_threshold">black_threshold</a></dt>
887
+
888
+ <dd>Force all pixels below the threshold into black</dd>
889
+
890
+ <dt><a href="image1.html#blur_image">blur_image</a>, <a href=
891
+ "image1.html#blur_channel">blur_channel</a>, <a href=
892
+ "image2.html#gaussian_blur">gaussian_blur</a>, <a href=
893
+ "image2.html#gaussian_blur_channel">gaussian_blur_channel</a>,
894
+ <a href="image3.html#motion_blur">motion_blur</a>, <a href=
895
+ "image3.html#radial_blur">radial_blur</a></dt>
896
+
897
+ <dd>Blur the image</dd>
898
+
899
+ <dt><a href=
900
+ "image1.html#channel_threshold">channel_threshold</a></dt>
901
+
902
+ <dd>Change the value of individual pixels based on the
903
+ intensity of each pixel channel</dd>
904
+
905
+ <dt><a href="image1.html#colorize">colorize</a></dt>
906
+
907
+ <dd>Blend the fill color with each pixel in the image</dd>
908
+
909
+ <dt><a href="image1.html#convolve">convolve</a>, <a href=
910
+ "image1.html#convolve_channel">convolve_channel</a></dt>
911
+
912
+ <dd>Apply a custom convolution kernel to the image</dd>
913
+
914
+ <dt><a href="image3.html#segment">segment</a></dt>
915
+
916
+ <dd>Segment an image by analyzing the histograms of the color
917
+ components and identifying units that are homogeneous with
918
+ the fuzzy c-means technique</dd>
919
+
920
+ <dt><a href="image3.html#threshold">threshold</a></dt>
921
+
922
+ <dd>Change the value of individual pixels based on the
923
+ intensity of each pixel compared to threshold</dd>
924
+
925
+ <dt><a href=
926
+ "image3.html#white_threshold">white_threshold</a></dt>
927
+
928
+ <dd>Force all pixels above the threshold into white</dd>
929
+ </dl>
930
+
931
+ <h4>Add special effects</h4>
932
+
933
+ <dl>
934
+ <dt><a href="image1.html#charcoal">charcoal</a></dt>
935
+
936
+ <dd>Add a charcoal effect</dd>
937
+
938
+ <dt><a href="image1.html#edge">edge</a></dt>
939
+
940
+ <dd>Find edges in the image</dd>
941
+
942
+ <dt><a href="image1.html#emboss">emboss</a></dt>
943
+
944
+ <dd>Add a three-dimensional effect</dd>
945
+
946
+ <dt><a href="image2.html#implode">implode</a></dt>
947
+
948
+ <dd>Implode or explode the center pixels in the image</dd>
949
+
950
+ <dt class="ilist"><a href="ilist.html#morph">morph</a></dt>
951
+
952
+ <dd class="ilist">Transform each image in the imagelist to
953
+ the next in sequence by creating intermediate images</dd>
954
+
955
+ <dt><a href="image2.html#oil_paint">oil_paint</a></dt>
956
+
957
+ <dd>Add an oil paint effect</dd>
958
+
959
+ <dt><a href="image3.html#shade">shade</a></dt>
960
+
961
+ <dd>Shine a distant light on an image to create a
962
+ three-dimensional effect</dd>
963
+
964
+ <dt><a href="image3.html#solarize">solarize</a></dt>
965
+
966
+ <dd>Apply a special effect to the image, similar to the
967
+ effect achieved in a photo darkroom by selectively exposing
968
+ areas of photo sensitive paper to light</dd>
969
+
970
+ <dt><a href="image3.html#spread">spread</a></dt>
971
+
972
+ <dd>Randomly displace each pixel in a block</dd>
973
+
974
+ <dt><a href="image3.html#stegano">stegano</a></dt>
975
+
976
+ <dd>Hide a digital watermark within the image</dd>
977
+
978
+ <dt><a href="image3.html#stereo">stereo</a></dt>
979
+
980
+ <dd>Combine two images into a single image that is the
981
+ composite of a left and right image of a stereo pair</dd>
982
+
983
+ <dt><a href="image3.html#swirl">swirl</a></dt>
984
+
985
+ <dd>Swirl the pixels about the center of the image</dd>
986
+
987
+ <dt><a href="image3.html#wave">wave</a></dt>
988
+
989
+ <dd>Add a ripple effect to the image</dd>
990
+ </dl>
991
+
992
+ <h4>Decorate</h4>
993
+
994
+ <dl>
995
+ <dt><a href="image1.html#border">border</a></dt>
996
+
997
+ <dd>Surround the image with a solid-colored border</dd>
998
+
999
+ <dt><a href="image2.html#frame">frame</a></dt>
1000
+
1001
+ <dd>Add a simulated three-dimensional border around the
1002
+ image</dd>
1003
+
1004
+ <dt><a href="image3.html#raise">raise</a></dt>
1005
+
1006
+ <dd>Create a simulated three-dimensional button-like effect
1007
+ by lightening and darkening the edges of the image</dd>
1008
+ </dl>
1009
+
1010
+ <h4>Create thumbnail montages</h4>
1011
+
1012
+ <dl>
1013
+ <dt class="ilist"><a href=
1014
+ "ilist.html#montage">montage</a></dt>
1015
+
1016
+ <dd class="ilist">Tile image thumbnails across a canvas</dd>
1017
+ </dl>
1018
+
1019
+ <h4>Create image blobs</h4>
1020
+
1021
+ <dl>
1022
+ <dt><a href="image1.html#from_blob">from_blob</a></dt>
1023
+
1024
+ <dd>Create an image from a BLOB</dd>
1025
+
1026
+ <dt class="ilist"><a href=
1027
+ "ilist.html#from_blob">from_blob</a></dt>
1028
+
1029
+ <dd class="ilist">Create an imagelist from one or more
1030
+ BLOBs</dd>
1031
+
1032
+ <dt><a href="image3.html#to_blob">to_blob</a></dt>
1033
+
1034
+ <dd>Construct a BLOB from an image</dd>
1035
+
1036
+ <dt class="ilist"><a href=
1037
+ "ilist.html#to_blob">to_blob</a></dt>
1038
+
1039
+ <dd class="ilist">Construct a BLOB from all the images in the
1040
+ imagelist</dd>
1041
+ </dl>
1042
+ </div>
1043
+
1044
+ <h2 id="marshaling">Marshaling images</h2>
1045
+
1046
+ <p>Image and ImageList objects can be serialized using Ruby's
1047
+ <code>Marshal</code> module. Marshaling is supported via
1048
+ &times;Magick's Binary Large OBject functions
1049
+ <code>ImageToBlob</code> (for dumping) and
1050
+ <code>BlobToImage</code> (for loading).</p>
1051
+
1052
+ <h4>Notes</h4>
1053
+
1054
+ <ol>
1055
+ <li>Some image formats cannot be dumped. The only way to be
1056
+ sure it will work is to try it.</li>
1057
+
1058
+ <li>Images in lossy formats, such as JPEG, will have a
1059
+ different signature after being reconstituted and therefore
1060
+ will not compare equal (using <a href=
1061
+ "image1.html#spaceship">&lt;=&gt;</a>) to the original
1062
+ image.</li>
1063
+ </ol>
1064
+
1065
+ <h2 id="drawing_on">Drawing on and adding text to images</h2>
1066
+
1067
+ <p>The <strong>Draw</strong> class is the third major class in
1068
+ the Magick module. This class defines two kinds of methods,
1069
+ <a href="#drawing">drawing</a> methods and <a href=
1070
+ "#annotation">annotation</a> methods.</p>
1071
+
1072
+ <h3 id="drawing">Drawing</h3>
1073
+
1074
+ <p>&times;Magick supports a set of 2D drawing commands that are
1075
+ very similar to the commands and elements defined by the W3C's
1076
+ <a href="http://www.w3.org/TR/SVG/index.html#minitoc">Scalable
1077
+ Vector Graphics (SVG) 1.1 Specification</a>. In RMagick, each
1078
+ command (called a <em>primitive</em>) is implemented as a method
1079
+ in the <code>Draw</code> class. To draw on an image, simply</p>
1080
+
1081
+ <ol>
1082
+ <li>Create an instance of the <code>Draw</code> class.</li>
1083
+
1084
+ <li>Call one or more primitive methods with the appropriate
1085
+ arguments.</li>
1086
+
1087
+ <li>Call the <a href="draw.html#draw"><code>draw</code></a>
1088
+ method.</li>
1089
+ </ol>
1090
+
1091
+ <p>The primitive methods do <em>not</em> draw anything directly.
1092
+ When you call a primitive method, you are simply adding the
1093
+ primitive and its arguments to a list of primitives stored in the
1094
+ <code>Draw</code> object. To "execute" the primitive list, call
1095
+ <code>draw</code>. Drawing the primitives does not destroy them.
1096
+ You can draw on another image by calling <code>draw</code> again,
1097
+ specifying a different image as the "canvas." Of course you can
1098
+ also draw on an image with multiple <code>Draw</code> objects,
1099
+ too. The canvas can be any image or imagelist, created by reading
1100
+ an image file or from scratch using
1101
+ <code>ImageList#new_image</code> or <code>Image.new</code>. (If
1102
+ you pass an imagelist object to <code>draw</code>, it draws on
1103
+ the current image.)</p>
1104
+
1105
+ <div id="axes">
1106
+ <a href="javascript:popup('axes.rb.html')"><img src=
1107
+ "ex/axes.gif" alt="Drawing coordinate system" title=
1108
+ "Click to see the example script" /></a>
1109
+
1110
+ <div>
1111
+ <p>Here's an illustration of the default drawing coordinate
1112
+ system. The origin is in the top left corner. The x axis
1113
+ extends to the right. The y axis extends downward. The units
1114
+ are pixels. 0&deg; is at 3 o'clock and rotation is clockwise.
1115
+ The units of rotation are usually degrees.<sup><a href=
1116
+ "#degrees">2</a></sup></p>
1117
+
1118
+ <p>You can change the default coordinate system by specifying
1119
+ a <em>scaling</em>, <em>rotation</em>, or
1120
+ <em>translation</em> transformation.</p>
1121
+
1122
+ <p><em>(Click the image to see the Ruby program that created
1123
+ it.)</em></p>
1124
+ </div>
1125
+ </div>
1126
+
1127
+ <p>RMagick's primitive methods include methods for drawing
1128
+ points, lines, Bezier curves, shapes such as ellipses and
1129
+ rectangles, and text. Shapes and lines have a fill color and a
1130
+ stroke color. Shapes are filled with the fill color unless the
1131
+ fill opacity is 0. Similarly, shapes are stroked with the stroke
1132
+ color unless the stroke opacity is 0. Text is considered a shape
1133
+ and is stroked and filled. Other rendering properties you can set
1134
+ include the stroke width, antialiasing, stroke patterns, and fill
1135
+ patterns.</p>
1136
+
1137
+ <p>As an example, here's the section of the Ruby program that
1138
+ created the circle in the center of the above image.</p>
1139
+ <pre class="example">
1140
+ 1. !# /usr/local/bin/ruby -w
1141
+ 2. require 'RMagick'
1142
+ 3.
1143
+ 4. canvas = Magick::ImageList.new
1144
+ 5. canvas.new_image(250, 250, Magick::HatchFill.new('white', 'gray90'))
1145
+ 6.
1146
+ 7. circle = Magick::Draw.new
1147
+ 8. circle.stroke('tomato')
1148
+ 9. circle.fill_opacity(0)
1149
+ 10. circle.stroke_opacity(0.75)
1150
+ 11. circle.stroke_width(6)
1151
+ 12. circle.stroke_linecap('round')
1152
+ 13. circle.stroke_linejoin('round')
1153
+ 14. circle.ellipse(canvas.rows/2,canvas.columns/2, 80, 80, 0, 315)
1154
+ 15. circle.polyline(180,70, 173,78, 190,78, 191,62)
1155
+ 16. circle.draw(canvas)
1156
+ </pre>
1157
+
1158
+ <p>The statements on lines 4 and 5 create the drawing canvas with
1159
+ a single 250x250 image. The <code>HatchFill</code> object fills
1160
+ the image with light-gray lines 10 pixels apart. The statement on
1161
+ line 7 creates a Draw object. The method calls on lines 8-15
1162
+ construct a list of primitives that are "executed" by the
1163
+ <code>draw</code> method call on line 16.</p>
1164
+
1165
+ <p>The <code>stroke</code> method sets the stroke color, as seen
1166
+ on line 8. Normally, shapes are filled (opacity = 1.0), but the
1167
+ call to <code>fill_opacity</code> on line 9 sets the opacity to
1168
+ 0, so the background will show through the circle. Similarly, the
1169
+ stroke lines are normally opaque, but the tomato-colored stroke
1170
+ line in this example is made slightly transparent by the call to
1171
+ <code>stroke_opacity</code> on line 10. The method calls on lines
1172
+ 11 through 13 set the stroke width and specify the appearance of
1173
+ the line ends and corners.</p>
1174
+
1175
+ <p>The <code>ellipse</code> method call on line 14 describes an
1176
+ circle in the center of the canvas with a radius of 80 pixels.
1177
+ The ellipse occupies 315&deg; of a circle, starting at 0&deg;
1178
+ (that is, 3 o'clock). The <code>polyline</code> call on line 15
1179
+ adds the arrowhead to the circle. The arguments (always an even
1180
+ number) are the x- and y-coordinates of the points the line
1181
+ passes through.</p>
1182
+
1183
+ <p>Finally, the <code>draw</code> method on line 16 identifies
1184
+ the canvas to be drawn on and executes the stored primitives.</p>
1185
+
1186
+ <h3 id="annotation">Annotation</h3>
1187
+
1188
+ <p>The <a href="draw.html#annotate"><code>annotate</code></a>
1189
+ method draws text on an image. In its simplest form,
1190
+ <code>annotate</code> requires only arguments that describe where
1191
+ to draw the text and the text string.</p>
1192
+
1193
+ <p>Most of the time, you'll want to specify text properties such
1194
+ as the font, its size, font styles such as italic, font weights
1195
+ such as bold, the fill and stroke color, etc. The Draw class
1196
+ defines <a href="draw.html#attribute_writers">attribute
1197
+ writers</a> for this purpose. You can set the desired text
1198
+ properties by calling the attribute writers before calling
1199
+ <code>annotate</code>, or you can call them in an image block
1200
+ associated with the <code>annotate</code> call.</p>
1201
+
1202
+ <p>The following example shows how to use <code>annotate</code>
1203
+ to produce this image.</p>
1204
+
1205
+ <div id="rubyname">
1206
+ <a href="javascript:popup('rubyname.rb.html')"><img src=
1207
+ "ex/rubyname.gif" alt="annotate example" title=
1208
+ "Click to see the example script" /></a>
1209
+ </div>
1210
+ <pre class="example">
1211
+ 1. #! /usr/local/bin/ruby -w
1212
+ 2. require 'RMagick'
1213
+ 3.
1214
+ 4. # Demonstrate the annotate method
1215
+ 5.
1216
+ 6. Text = 'RMagick'
1217
+ 7.
1218
+ 8. granite = Magick::ImageList.new('granite:')
1219
+ 9. canvas = Magick::ImageList.new
1220
+ 10. canvas.new_image(300, 100, Magick::TextureFill.new(granite))
1221
+ 11.
1222
+ 12. text = Magick::Draw.new
1223
+ 13. text.font_family = 'helvetica'
1224
+ 14. text.pointsize = 52
1225
+ 15. text.gravity = Magick::CenterGravity
1226
+ 16.
1227
+ 17. text.annotate(canvas, 0,0,2,2, Text) {
1228
+ 18. self.fill = 'gray83'
1229
+ 19. }
1230
+ 20.
1231
+ 21. text.annotate(canvas, 0,0,-1.5,-1.5, Text) {
1232
+ 22. self.fill = 'gray40'
1233
+ 23. }
1234
+ 24.
1235
+ 25. text.annotate(canvas, 0,0,0,0, Text) {
1236
+ 26. self.fill = 'darkred'
1237
+ 27. }
1238
+ 28.
1239
+ 29. canvas.write('rubyname.gif')
1240
+ 30. exit
1241
+ </pre>
1242
+
1243
+ <p>This program uses three calls to <code>annotate</code> to
1244
+ produce the "etched" appearance. All three calls have some
1245
+ parameters in common but the fill color and location are
1246
+ different.</p>
1247
+
1248
+ <p>First, the statements in lines 8-10 create the background. See
1249
+ <a href="struct.html#fill"><code>Fill classes</code></a> for
1250
+ information about the <code>TextureFill</code> class. The
1251
+ "granite:" image format is one of &times;Magick's built-in image
1252
+ formats. See <a href="imusage.html#builtin_formats">"Built-in
1253
+ image formats"</a> for more information. The statement on line 12
1254
+ creates the Draw object that does the annotation. The next 3
1255
+ lines set the values of the attributes that are common to all 3
1256
+ <code>annotate</code> calls.</p>
1257
+
1258
+ <p>The first <code>annotate</code> argument is the image on which
1259
+ the text will be drawn. Arguments 2-5, <code>width</code>,
1260
+ <code>height</code>, <code>x</code>, and <code>y</code>, describe
1261
+ a rectangle about which the text is drawn. This rectangle,
1262
+ combined with the value of <code>gravity</code>, define the
1263
+ position of the text. When the <code>gravity</code> value is
1264
+ <a href=
1265
+ "constants.html#GravityType"><code>CenterGravity</code></a> the
1266
+ values of <code>width</code> and <code>height</code> are
1267
+ unused.</p>
1268
+
1269
+ <p>The first call to <code>annotate</code>, on lines 17-19, draws
1270
+ the text 2 pixels to the right and down from the center. The
1271
+ <code>self.fill = 'gray83'</code> statement sets the text color
1272
+ to light gray. The second call to <code>annotate</code>, on lines
1273
+ 21-22, draws dark gray text 1.5 pixels to the left and up from
1274
+ the center. The last call, on lines 25-27, draws the text a third
1275
+ time, in dark red, exactly in the center of the image.</p>
1276
+
1277
+ <h2 id="more">Where to go from here</h2>
1278
+
1279
+ <p>The next section, <a href=
1280
+ "imusage.html">"ImageMagick/GraphicsMagick Conventions,"</a>
1281
+ describes some conventions that you need to know, such as how
1282
+ &times;Magick determines the graphic format of an image file,
1283
+ etc. The ImageMagick (www.imagemagick.org) and GraphicsMagick
1284
+ (www.graphicsmagick.org) web sites (from which much of the
1285
+ information in these pages has been taken) offers a lot of detail
1286
+ about &times;Magick. While these web sites don't describe
1287
+ RMagick, you can often use the documentation to learn more about
1288
+ a RMagick method by reading about the Magick API the method
1289
+ calls. (In the Reference section of this document, most of the
1290
+ method descriptions include the name of the Magick API that the
1291
+ method calls.) Check out the example programs. Almost every one
1292
+ of the methods is demonstrated in one of the examples.</p>
1293
+
1294
+ <p>Good luck!</p>
1295
+
1296
+ <div>
1297
+ <h5 id="footnotes">Footnotes</h5>
1298
+
1299
+ <p id="display"><sup>1</sup>The <code>display</code> and
1300
+ <code>animate</code> methods do not work on MS Windows. You
1301
+ will have to write the image to a file and view it with a
1302
+ separate image viewer.</p>
1303
+
1304
+ <p id="degrees"><sup>2</sup>The rotation attributes
1305
+ <code>rx</code> and <code>ry</code> in the <a href=
1306
+ "struct.html#AffineMatrix"><code>AffineMatrix</code></a> class
1307
+ use radians instead of degrees.</p>
1308
+ </div>
1309
+
1310
+ <p class="spacer"> </p>
1311
+
1312
+ <div class="nav">
1313
+ &laquo; <a href="index.html">Prev</a> | <a href=
1314
+ "index.html">Contents</a> | <a href="imusage.html">Next</a>
1315
+ &raquo;
1316
+ </div>
1317
+ </body>
1318
+ </html>