<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta name="generator" content= "HTML Tidy for Linux/x86 (vers 1 September 2005), see www.w3.org" /> <title>RMagick 2.1.0: class Image (instance methods p-w)</title> <meta http-equiv="Content-Type" content= "text/html; charset=us-ascii" /> <meta name="GENERATOR" content="Quanta Plus" /> <meta name="Copyright" content= "Copyright (C) 2006 by Timothy P. Hunter" /> <link rel="stylesheet" type="text/css" href="css/doc.css" /> <script type="text/javascript" src="scripts/doc.js"> </script> <script type="text/javascript"> //<![CDATA[ <!-- Pre-load this image so that the browser knows how big it is. --> <!-- Begin flower_hat = new Image(); flower_hat.src = "ex/images/Flower_Hat.jpg"; // End --> //]]> </script> <style type="text/css"> /*<![CDATA[*/ /* * This style is used for the list of PreviewType * constants defined for the preview method, below. */ #prevlist ul { float: left; list-style: none; margin-bottom: 0; } /* * This style is used for the list of QuantumOperator * constants defined for the quantum_operator method, below. * */ #quantum_op_list { list-style-type: none; } /*]]>*/ </style> </head> <body> <h6 id="header">RMagick 2.1.0 User's Guide and Reference</h6> <div class="nav"> « <a href="image2.html">Prev</a> | <a href= "index.html">Contents</a> | <a href= "draw.html">Next</a> » </div> <h1>class Image <span class="superclass">< Object</span> (instance methods p-w)<br /> <span class="mixin">mixes in Comparable</span></h1> <div id="toc"> <h2>Table of Contents</h2> <h3>instance methods</h3> <div> <div class="toccol"> <ul> <li><a href="#palette_q">palette?</a></li> <li><a href="#pixel_color">pixel_color</a></li> <li><a href="#polaroid">polaroid</a></li> <li><a href="#posterize">posterize</a></li> <li><a href="#preview">preview</a></li> <li><a href="#profile_bang">profile!</a></li> <li><a href="#properties">properties</a></li> <li><a href="#quantize">quantize</a></li> <li><a href="#quantum_operator">quantum_operator</a></li> <li><a href="#radial_blur">radial_blur</a></li> <li><a href= "#radial_blur_channel">radial_blur_channel</a></li> <li><a href="#raise">raise</a></li> <li><a href= "#random_threshold_channel">random_threshold_channel</a></li> <li><a href="#recolor">recolor</a></li> <li><a href="#reduce_noise">reduce_noise</a></li> <li><a href="#resample">resample</a></li> <li><a href="#resize">resize</a></li> <li><a href="#resize_bang">resize!</a></li> <li><a href="#resize_to_fill">resize_to_fill</a></li> <li><a href= "#resize_to_fill_bang">resize_to_fill!</a></li> <li><a href="#resize_to_fit">resize_to_fit</a></li> <li><a href="#resize_to_fit_bang">resize_to_fit!</a></li> <li><a href="#roll">roll</a></li> <li><a href="#rotate">rotate</a></li> <li><a href="#rotate_bang">rotate!</a></li> </ul> </div> <div class="toccol"> <ul> <li><a href="#sample">sample</a></li> <li><a href="#sample_bang">sample!</a></li> <li><a href="#scale">scale</a></li> <li><a href="#scale_bang">scale!</a></li> <li><a href="#segment">segment</a></li> <li><a href="#separate">separate</a></li> <li><a href="#sepiatone">sepiatone</a></li> <li><a href= "#set_channel_depth">set_channel_depth</a></li> <li><a href="#shade">shade</a></li> <li><a href="#shadow">shadow</a></li> <li><a href="#sharpen">sharpen</a></li> <li><a href="#sharpen_channel">sharpen_channel</a></li> <li><a href="#shave">shave</a></li> <li><a href="#shave_bang">shave!</a></li> <li><a href="#shear">shear</a></li> <li><a href= "#sigmoidal_contrast_channel">sigmoidal_contrast_channel</a></li> <li><a href="#signature">signature</a></li> <li><a href="#sketch">sketch</a></li> <li><a href="#solarize">solarize</a></li> <li><a href="#splice">splice</a></li> <li><a href="#spread">spread</a></li> <li><a href="#stegano">stegano</a></li> <li><a href="#stereo">stereo</a></li> <li><a href="#store_pixels">store_pixels</a></li> <li><a href="#strip_bang">strip!</a></li> </ul> </div> <div class="toccol"> <ul> <li><a href="#swirl">swirl</a></li> <li><a href="#sync_profiles">sync_profiles</a></li> <li><a href= "#texture_fill_to_border">texture_fill_to_border</a></li> <li><a href= "#texture_floodfill">texture_floodfill</a></li> <li><a href="#threshold">threshold</a></li> <li><a href="#thumbnail">thumbnail</a></li> <li><a href="#thumbnail_bang">thumbnail!</a></li> <li><a href="#to_blob">to_blob</a></li> <li><a href="#to_color">to_color</a></li> <li><a href="#transparent">transparent</a></li> <li><a href="#transpose">transpose</a></li> <li><a href="#transpose_bang">transpose!</a></li> <li><a href="#transverse">transverse</a></li> <li><a href="#transverse_bang">transverse!</a></li> <li><a href="#trim">trim</a></li> <li><a href="#trim_bang">trim!</a></li> <li><a href="#unique_colors">unique_colors</a></li> <li><a href="#unsharp_mask">unsharp_mask</a></li> <li><a href= "#unsharp_mask_channel">unsharp_mask_channel</a></li> <li><a href="#view">view</a></li> <li><a href="#vignette">vignette</a></li> <li><a href="#watermark">watermark</a></li> <li><a href="#wave">wave</a></li> <li><a href="#wet_floor">wet_floor</a></li> <li><a href="#white_threshold">white_threshold</a></li> <li><a href="#write">write</a></li> </ul> </div> </div> </div> <h2 class="methods">instance methods</h2> <div class="sig"> <h3 id="palette_q">palette?</h3> <p><span class="arg">img</span>.palette? -> true or false</p> </div> <div class="desc"> <h4>Description</h4> <p class="imquote">Returns true if the image is <a href= "constants.html#ClassType">PseudoClass</a> and has 256 unique colors or less.</p> <h4>Returns</h4> <p>true or false</p> <h4>Magick API</h4> <p>IsPaletteImage</p> </div> <div class="sig"> <h3 id="pixel_color">pixel_color</h3> <p><span class="arg">img</span>.pixel_color(<span class= "arg">x</span>, <span class="arg">y</span>[, <span class= "arg">new_color</span>]) -> <em>pixel</em></p> </div> <div class="desc"> <h4>Description</h4> <p>Returns the color of the pixel at <span class= "arg">x</span>, <span class="arg">y</span>. Optionally, changes the color of the pixel to a new color.</p> <p>If new_color is specified, pixel_color changes the image type to DirectClass if necessary.</p> <h4>Arguments</h4> <dl> <dt>x, y</dt> <dd>The x- and y-coordinates of the pixel.</dd> <dt>new_color</dt> <dd>If specified, the pixel is set to this color. May be either a <a href="imusage.html#color_names">color name</a> or a <a href="struct.html#Pixel">Pixel</a>.</dd> </dl> <h4>Returns</h4>A <a href="struct.html#Pixel">Pixel</a> having the RGB values of the specified pixel. <h4>Example</h4> <pre> old = image.pixel_color(20,40,"white") </pre> <h4>Magick API</h4> <p>AcquireImagePixels</p> </div> <div class="sig"> <h3 id="polaroid">polaroid</h3> <p><span class="arg">img</span>.polaroid(angle=-5.0) [ <span class="arg">{ optional arguments }</span> ] -> image</p> </div> <div class="desc"> <h4>Description</h4> <p>Produce an image that looks like a Polaroid® instant picture. If the image has a "Caption" <a href= "image1.html#aset">property</a>, the value is used as a caption.</p> <p>Optional arguments may be specified in a block associated with the method. These arguments control the shadow color and how the label is rendered. By default the shadow color is gray75. To specify a different shadow color, use <code>self.shadow_color</code>. To specify a different border color (that is, the color of the image border) use <code>self.border_color</code>. Both of these methods accept either a <a href="imusage.html#color_names">color name</a> or a <a href="struct.html#Pixel">Pixel</a> argument.</p> <p>The following <a href="draw.html#annotate">annotate</a> attributes control the label rendering: <a href= "draw.html#align_eq">align</a>, <a href= "draw.html#decorate_eq">decorate</a>, <a href= "draw.html#density_eq">density</a>, <a href= "draw.html#encoding_eq">encoding</a>, <a href= "draw.html#fill_eq">fill</a>, <a href= "draw.html#font_eq">font</a>, <a href= "draw.html#font_family_eq">font_family</a>, <a href= "draw.html#font_stretch_eq">font_stretch</a>, <a href= "draw.html#font_style_eq">font_style</a>, <a href= "draw.html#font_weight_eq">font_weight</a>, <a href= "draw.html#gravity_eq">gravity</a>, <a href= "draw.html#pointsize_eq">pointsize</a>, <a href= "draw.html#stroke_eq">stroke</a>, <a href= "draw.html#stroke_width_eq">stroke_width</a>, <a href= "draw.html#text_antialias_eq">text_antialias</a>, <a href= "draw.html#undercolor_eq">undercolor</a>.</p> <pre> img.polaroid do self.shadow_color = "gray40" self.pointsize = 12 end </pre> <h4>Arguments</h4> <dl> <dt>angle</dt> <dd>The resulting image is rotated by this amount, measured in degrees. The default is -5.0.</dd> </dl> <h4>Example</h4> <p><a href="javascript:popup('polaroid.rb.html')"><img src= "ex/polaroid.jpg" alt="polaroid example" /></a></p> <h4>Magick API</h4> <p>PolaroidImage</p> <h4>See also</h4> <p><a href= "http://rmagick.rubyforge.org/Polaroid/polaroid.html">The Polaroid Effect</a></p> <h4>Notes</h4> <p>"Polaroid" and the other names of products of Polaroid Corporation are trademarks of Polaroid Corporation.</p> </div> <div class="sig"> <h3 id="posterize">posterize</h3> <p><span class="arg">img</span>.posterize(<span class= "arg">levels</span>=4, <span class="arg">dither</span>=false) -> <em>image</em></p> </div> <div class="desc"> <h4>Description</h4> <p class="imquote">Reduces the image to a limited number of colors for a "poster" effect.</p> <h4>Arguments</h4> <dl> <dt>levels</dt> <dd><span class="imquote">Number of color levels allowed in each channel. Very low values (2, 3, or 4) have the most visible effect.</span> The default is 4.</dd> <dt>dither</dt> <dd>If true, dither the image. The default is false.</dd> </dl> <h4>Returns</h4> <p>A new image</p> <h4>Example</h4> <p class="rollover"><a href= "javascript:popup('posterize.rb.html')"><img src= "ex/posterize.jpg" alt="posterize example" onmouseover= "this.src='ex/images/Flower_Hat.jpg'" onmouseout= "this.src='ex/posterize.jpg'" title= "Click to see the example script" /></a> <img src= "ex/images/spin.gif" alt="" class="spin" title= "Mouse over the example to see the original image" /></p> <h4>See also</h4> <p><a href="image2.html#ordered_dither">ordered_dither</a>, <a href="image3.html#quantize">quantize</a></p> <h4>Magick API</h4> <p>PosterizeImage</p> </div> <div class="sig"> <h3 id="preview">preview</h3> <p><span class="arg">img</span>.preview(<span class= "arg">aPreviewType</span>) -> <em>image</em></p> </div> <div class="desc"> <h4>Description</h4> <p>Creates an image that contains 9 small versions of the receiver image. The center image is the unchanged receiver. The other 8 images are variations created by transforming the receiver according to the specified preview type with varying parameters.</p> <p>A preview image is an easy way to "try out" a transformation method.</p> <h4>Arguments</h4> <p>One of the following PreviewType constants:</p> <div id="prevlist"> <ul> <li>RotatePreview</li> <li>ShearPreview</li> <li>RollPreview</li> <li>HuePreview</li> <li>SaturationPreview</li> <li>BrightnessPreview</li> <li>GammaPreview</li> <li>SpiffPreview</li> <li>DullPreview</li> <li>GrayscalePreview</li> <li>QuantizePreview</li> <li>DespecklePreview</li> <li>ReduceNoisePreview</li> <li>AddNoisePreview</li> <li>SharpenPreview</li> </ul> <ul> <li>BlurPreview</li> <li>ThresholdPreview</li> <li>EdgeDetectPreview</li> <li>SpreadPreview</li> <li>SolarizePreview</li> <li>ShadePreview</li> <li>RaisePreview</li> <li>SegmentPreview</li> <li>SwirlPreview</li> <li>ImplodePreview</li> <li>WavePreview</li> <li>OilPaintPreview</li> <li>CharcoalDrawingPreview</li> <li>JPEGPreview</li> </ul> </div> <div style="clear:both"></div> <h4>Returns</h4> <p>A new image</p> <h4>Example</h4> <p>This half-size preview demonstrates the SolarizePreview argument.</p> <p><a href="javascript:popup('preview.rb.html')"><img src= "ex/preview.jpg" alt="preview example" title= "Click to see the example script" /></a></p> <h4>Magick API</h4> <p>PreviewImage</p> </div> <div class="sig"> <h3 id="profile_bang">profile!</h3> <p><span class="arg">img</span>.profile!(<span class= "arg">name</span>, <span class="arg">profile</span>) -> <em>self</em></p> </div> <div class="desc"> <h4>Description</h4> <p><span class="imquote">Adds or removes a ICM, IPTC, or generic profile from an image.</span> If <code>profile</code> is <code>nil</code>, the specified profile is removed from the image. Use <code>profile('*', nil)</code> to remove all profiles from the image.</p> <h4>Arguments</h4> <dl> <dt>name</dt> <dd>The profile name, or "*" to represent all the profiles in the image.</dd> <dt>profile</dt> <dd>The profile value, or <code>nil</code> to cause the profile to be removed.</dd> </dl> <h4>Returns</h4> <p>self</p> <h4>See also</h4> <p><a href="image1.html#add_profile">add_profile</a> and <a href="image1.html#delete_profile">delete_profile</a> perform very similar functions. However, <code>add_profile</code> accepts the name of a profile file on disk instead of the profile data itself and, if the file contains more than one profile, will load all the profiles at once.</p> <h4>Magick API</h4> <p>ProfileImage</p> <h4>Notes</h4> <p>ImageMagick does not automatically remove profiles when resizing images. If you are trying to make your JPEG thumbnail images as small as possible, use <code>profile!</code> to remove any profiles from the image as well. Also see <a href= "#strip_bang">strip!</a></p> </div> <div class="sig"> <h3 id="properties">properties</h3> <p><span class="arg">img</span>.properties <span class="arg">[ {|name,value| block} ]</span> -> <em>hash</em></p> </div> <div class="desc"> <h4>Description</h4> <p>If called with an associated block, <code>properties</code> runs the block once for each property defined for the image. The block arguments are the property name and its value. If there is no block, <code>properties</code> returns a hash with one element for each property. The hash key is the property name and the associated value is the property value.</p> <h4>Returns</h4> <p>If called without a block, returns a hash, otherwise returns <code>self</code>.</p> <h4>See also</h4> <p><a href="image1.html#aref">[ ]</a>, <a href= "image1.html#aset">[ ]=</a></p> <h4>Note</h4> <p>The EXIF property is not created until the first time an EXIF tag or entry number is referenced.</p> </div> <div class="sig"> <h3 id="quantize">quantize</h3> <p><span class="arg">img</span>.quantize(<span class= "arg">number_colors</span>=256, <span class= "arg">colorspace</span>=RGBColorspace, <span class= "arg">dither</span>=<code>true</code>, <span class= "arg">tree_depth</span>=0, <span class= "arg">measure_error</span>=<code>false</code>) -> <em>image</em></p> </div> <div class="desc"> <h4>Description</h4> <p class="imquote">Analyzes the colors within a reference image and chooses a fixed number of colors to represent the image. The goal of the algorithm is to minimize the difference between the input and output image while minimizing the processing time.</p> <h4>Arguments</h4> <dl> <dt>number_colors</dt> <dd>The maximum number of colors in the result image. Must be <= <a href= "constants.html#Miscellaneous_constants">QuantumRange</a>.</dd> <dt>colorspace</dt> <dd class="imquote">The <a href= "constants.html#ColorspaceType">colorspace</a> to quantize in. Color reduction, by default, takes place in the RGB color space. Empirical evidence suggests that distances in color spaces such as YUV or YIQ correspond to perceptual color differences more closely than do distances in RGB space. The Transparent color space behaves uniquely in that it preserves the matte channel of the image if it exists.</dd> <dt>dither</dt> <dd>Set to <code>false</code> to disable dithering. See the documentation for the <a href= "http://redux.imagemagick.org/script/command-line-options.php#dither"> ImageMagick -dither option</a> for more information.</dd> <dt>tree_depth</dt> <dd><span class="imquote">The tree depth to use while quantizing. The values 0 and 1 support automatic tree depth determination. The tree depth may be forced via values ranging from 2 to 8. The ideal tree depth depends on the characteristics of the input image, and may be determined through experimentation.</span> See the documentation for the <a href= "http://redux.imagemagick.org/script/command-line-options.php#treedepth"> ImageMagick -treedepth option</a> for more information.</dd> <dt>measure_error</dt> <dd class="imquote">Set to <code>true</code> to calculate quantization errors when quantizing the image.</dd> </dl> <h4>Returns</h4> <p>A new image</p> <h4>Example</h4> <p>See the example for <a href= "image1.html#colorize">colorize</a>.</p> <h4>See also</h4> <p><a href="image2.html#ordered_dither">ordered_dither</a>, <a href="image3.html#posterize">posterize</a>, <a href= "ilist.html#quantize">ImageList#quantize</a></p> <h4>Magick API</h4> <p>QuantizeImage</p> </div> <div class="sig"> <h3 id="quantum_operator">quantum_operator</h3> <p><span class="arg">img</span>.quantum_operator(<span class= "arg">operator</span>, <span class="arg">rvalue</span>, <span class="arg">channel</span>=AllChannels) -> <em>self</em></p> </div> <div class="desc"> <h4>Description</h4> <p>Performs the requested integer arithmetic operation on the selected channel of the image. This method allows simple arithmetic operations on the component values of all pixels in an image. Of course, you could also do this in Ruby using <a href="image2.html#get_pixels">get_pixels</a> and <a href= "#store_pixels">store_pixels</a>, or <a href="#view">view</a>, but <code>quantum_operator</code> will be faster, especially for large numbers of pixels, since it does not need to convert the pixels from C to Ruby.</p> <h4>Arguments</h4> <dl> <dt>operator</dt> <dd> One of the following <code>QuantumExpressionOperator</code> constants: <ul id="quantum_op_list"> <li>AddQuantumOperator</li> <li><code>AndQuantumOperator</code></li> <li><code>DivideQuantumOperator</code></li> <li><code>LShiftQuantumOperator</code></li> <li><code>MaxQuantumOperator</code></li> <li><code>MinQuantumOperator</code></li> <li><code>MultiplyQuantumOperator</code></li> <li><code>OrQuantumOperator</code></li> <li><code>RShiftQuantumOperator</code></li> <li><code>SubtractQuantumOperator</code></li> <li><code>XorQuantumOperator</code></li> </ul> </dd> <dt>rvalue</dt> <dd>a <code>Numeric</code> operation rvalue.</dd> <dt>channel</dt> <dd>A <a href="constants.html#ChannelType">ChannelType</a> value. The default is to operate on all channels.</dd> </dl> <h4>Returns</h4> <p>self</p> <h4>Example</h4> <p>Divide the red component of all the pixels in the image by 2:</p> <pre> img.quantum_operator(DivideQuantumOperator, 2, RedChannel) </pre> <h4>See also</h4> <p>The <a href="struct.html#view">Image:View</a> class supports operations on individual pixels and collections of pixels, as well as operations on channels within pixels. See <a href= "#view">view</a>, below.</p> <h4>Magick API</h4> <p>EvaluateImageChannel</p> </div> <div class="sig"> <h3 id="radial_blur">radial_blur</h3> <p><span class="arg">img</span>.radial_blur(<span class= "arg">float</span>) -> <em>image</em></p> </div> <div class="desc"> <h4>Description</h4> <p class="imquote">Applies a radial blur to the image.</p> <h4>Arguments</h4> <dl> <dt>angle</dt> <dd>Amount of blur, in degrees</dd> </dl> <h4>Returns</h4> <p>A new image</p> <h4>Example</h4> <p class="rollover"><a href= "javascript:popup('radial_blur.rb.html')"><img src= "ex/radial_blur.jpg" onmouseover= "this.src='ex/images/Flower_Hat.jpg'" onmouseout= "this.src='ex/radial_blur.jpg'" alt="radial_blur example" title="Click to see the example script" /></a> <img src= "ex/images/spin.gif" alt="" class="spin" title= "Mouse over the example to see the original image" /></p> <h4>See also</h4> <p><a href="image1.html#blur_image">blur_image</a>, <a href= "image2.html#gaussian_blur">gaussian_blur</a>, <a href= "image2.html#motion_blur">motion_blur</a>, <a href= "#radial_blur_channel">radial_blur_channel</a></p> <h4>Magick API</h4> <p>RadialBlurImage</p> </div> <div class="sig"> <h3 id="radial_blur_channel">radial_blur_channel</h3> <p><span class= "arg">img</span>.radial_blur_channel(<span class="arg">float</span> [, <span class="arg">channel</span>...]) -> <em>image</em></p> </div> <div class="desc"> <h4>Description</h4> <p>Applies a radial blur to the selected image channels.</p> <h4>Arguments</h4> <dl> <dt>angle</dt> <dd>Amount of blur, in degrees</dd> <dt>channel...</dt> <dd>0 or more <a href= "constants.html#ChannelType">ChannelType</a> arguments. If no channels are specified, all the channels are blurred.</dd> </dl> <h4>Returns</h4> <p>A new image</p> <h4>See also</h4> <p><a href="#radial_blur">radial_blur</a></p> <h4>Magick API</h4> <p>RadialBlurImageChannel</p> </div> <div class="sig"> <h3 id="raise">raise</h3> <p><span class="arg">img</span>.raise(<span class= "arg">width</span>=6, <span class="arg">height</span>=6, <span class="arg">raised</span>=<code>true</code>) -> <em>image</em></p> </div> <div class="desc"> <h4>Description</h4> <p class="imquote">Creates a simulated three-dimensional button-like effect by lightening and darkening the edges of the image.</p> <h4>Arguments</h4> <dl> <dt>width</dt> <dd>The width of the raised edge in pixels. The default is 6.</dd> <dt>height</dt> <dd>The height of the raised edge in pixels. The default is 6.</dd> <dt>raised</dt> <dd>If <code>true</code>, the image is raised, otherwise lowered.</dd> </dl> <h4>Returns</h4> <p>A new image</p> <h4>Example</h4> <p class="rollover"><a href= "javascript:popup('raise.rb.html')"><img src="ex/raise.jpg" onmouseover="this.src='ex/images/Flower_Hat.jpg'" onmouseout= "this.src='ex/raise.jpg'" alt="raise example" title= "Click to see the example script" /></a> <img src= "ex/images/spin.gif" alt="" class="spin" title= "Mouse over the example to see the original image" /></p> <h4>Magick API</h4> <p>RaiseImage</p> </div> <div class="sig"> <h3 id="random_threshold_channel">random_threshold_channel</h3> <p><span class="arg">img</span>.random_threshold_channel( <span class="arg">thresholds</span>, [<span class= "arg">channel</span>...] ) -> <em>image</em></p> </div> <div class="desc"> <h4>Description</h4> <p class="imquote">Changes the value of individual pixels based on the intensity of each pixel compared to a random threshold. The result is a low-contrast, two color image.</p> <h4>Arguments</h4> <dl> <dt>thresholds</dt> <dd><span class="imquote">A geometry string containing LOWxHIGH thresholds.</span> The string is in the form `XxY'. The Y value may be omitted, in which case it is assigned the value QuantumRange-X. If an % appears in the string then the values are assumed to be percentages of QuantumRange. <span class="imquote">If the string contains 2x2, 3x3, or 4x4, then an ordered dither of order 2, 3, or 4 will be performed instead.</span> A <a href= "struct.html#Geometry">Geometry</a> object may be used as well.</dd> <dt>channel...</dt> <dd>0 or more <a href= "constants.html#ChannelType">ChannelType</a> arguments. If no channels are specified, all the channels are thresholded.</dd> </dl> <h4>Returns</h4> <p>A new image</p> <h4>Example</h4> <pre> geom = Geometry.new(QuantumRange/2) random_threshold_channel(geom, RedChannel) </pre> <p class="rollover"><a href= "javascript:popup('random_threshold_channel.rb.html')"><img src="ex/random_threshold_channel.jpg" alt="random_threshold_channel example" title= "Click to see the example script" onmouseover= "this.src='ex/images/Flower_Hat.jpg'" onmouseout= "this.src='ex/random_threshold_channel.jpg'" /></a> <img src= "ex/images/spin.gif" alt="" class="spin" title= "Mouse over the example to see the original image" /></p> <h4>See also</h4> <p><a href= "image1.html#adaptive_threshold">adaptive_threshold</a>, <a href="image1.html#bilevel_channel">bilevel_channel</a>, <a href="#threshold">threshold</a></p> <h4>Magick API</h4> <p>RandomThresholdImageChannel</p> </div> <div class="sig"> <h3 id="recolor">recolor</h3> <p><span class="arg">img</span>.recolor(<span class= "arg">color_matrix</span>) -> <em>image</em></p> </div> <div class="desc"> <h4>Description</h4> <p>Use this method to <span class="imquote">translate, scale, shear, or rotate image colors. Although you can use variable sized matrices, typically you use a 5×5 for an RGBA image and a 6×6 for CMYKA. Populate the last row with normalized values to translate.</span></p> <h4>Arguments</h4> <p>An array of Float values representing the recolor matrix.</p> <h4>Magick API</h4> <p>RecolorImage</p> </div> <div class="sig"> <h3 id="reduce_noise">reduce_noise</h3> <p><span class="arg">img</span>.reduce_noise(<span class= "arg">radius</span>) -> <em>image</em></p> </div> <div class="desc"> <h4>Description</h4> <p class="imquote">Smooths the contours of an image while still preserving edge information. The algorithm works by replacing each pixel with its neighbor closest in value.</p> <h4>Arguments</h4> <dl> <dt>radius</dt> <dd class="imquote">A neighbor is defined by radius. Use a radius of 0 and <code>reduce_noise</code> selects a suitable radius for you.</dd> </dl> <h4>Returns</h4> <p>A new image</p> <h4>Example</h4> <p>The left side of the image has been modified by <a href= "#Image.add_noise"><code>add_noise</code></a>. The right side has been filtered by <code>reduce_noise(0)</code>.</p> <p><a href="javascript:popup('reduce_noise.rb.html')"><img src= "ex/reduce_noise.jpg" title="Click to see the example script" alt="reduce_noise example" /></a></p> <h4>See also</h4> <p><a href="image2.html#enhance">enhance</a>, <a href= "#unsharp_mask">unsharp_mask</a></p> <h4>Magick API</h4> <p>ReduceNoiseImage</p> </div> <div class="sig"> <h3 id="resample">resample</h3> <p><span class="arg">img</span>.resample(<span class= "arg">horizontal_res</span>=72.0[, <span class= "arg">vertical_res</span>]) -> <em>image</em></p> </div> <div class="desc"> <h4>Description</h4> <p class="imquote">Resample image to specified horizontal and vertical resolution.</p> <p><span class="imquote">Resize the image so that its rendered size remains the same as the original at the specified target resolution. For example, if a 300 DPI image renders at 3 inches by 2 inches on a 300 DPI device, when the image has been resampled to 72 DPI, it will render at 3 inches by 2 inches on a 72 DPI device. Note that only a small number of image formats (e.g. JPEG, PNG, and TIFF) are capable of storing the image resolution. For formats which do not support an image resolution, the original resolution of the image must be specified via</span> the <a href= "imageattrs.html#density">density</a> attribute <span class= "imquote">prior to specifying the resample resolution.</span></p> <h4>Arguments</h4> <dl> <dt>horizontal_res</dt> <dd>the target horizontal resolution. The default is 72.0.</dd> <dt>vertical_res</dt> <dd>the target vertical resolution. The default is <span class="arg">horizontal_res</span>.</dd> </dl> </div> <div class="sig"> <h3 id="resize">resize</h3> <p><span class="arg">img</span>.resize(<span class= "arg">new_width</span>, <span class="arg">new_height</span>, <em>filter</em>=<a href= "constants.html#FilterTypes">LanczosFilter</a>, <em>support</em>=1.0) -> <em>image</em><br /> <span class="arg">img</span>.resize(<span class= "arg">scale_factor</span>) -> <em>image</em></p> </div> <div class="desc"> <h4>Description</h4> <p>Changes the size of the receiver to the specified dimensions.</p> <h4>Arguments</h4> <p>You can specify the new size in two ways. Either specify the new width and height explicitly, or specify a <em>scale factor</em>, a number that represents the percentage change.</p> <p>Use the <a href= "image1.html#change_geometry">change_geometry</a> method to resize an image with constraints such as "maintain the current proportions."</p> <dl> <dt>new_width, new_height</dt> <dd>The desired width and height.</dd> <dt>filter</dt> <dd>The <a href="constants.html#FilterTypes">filter</a> to use when resizing. If you do not specify a filter argument, resize uses the value of the receiver's <a href= "imageattrs.html#Image.filter">filter attribute</a>. <span class="imquote">Most of the filters are FIR (finite impulse response), however, Bessel, Gaussian, and Sinc are IIR (infinite impulse response). Bessel and Sinc are windowed (brought down to zero) with the Blackman filter.</span></dd> <dt>support</dt> <dd>Values > 1 increase the blurriness. Values < 1 increase the sharpness. If this argument is not specified, <code>resize</code> uses the value of the receiver's <a href= "imageattrs.html#Image.blur">blur</a> attribute.</dd> <dt>scale_factor</dt> <dd>You can use this argument instead of specifying the desired width and height. The percentage size change. For example, 1.25 makes the new image 125% of the size of the receiver. The scale factor 0.5 makes the new image 50% of the size of the receiver.</dd> </dl> <h4>Returns</h4> <p>A new image</p> <h4>See also</h4> <p><a href="image1.html#change_geometry">change_geometry</a>, <a href="#resize_bang">resize!</a>, <a href= "image2.html#magnify">magnify</a>, <a href= "image2.html#minify">minify</a>, <a href="#sample">sample</a>, <a href="#scale">scale</a>, <a href= "thumbnail">thumbnail</a></p> <h4>Magick API</h4> <p>ResizeImage</p> </div> <div class="sig"> <h3 id="resize_bang">resize!</h3> <p><span class="arg">img</span>.resize!(<em>new_width</em>, <em>new_height</em>, <em>filter</em>=<a href= "constants.html#FilterTypes">LanczosFilter</a>, <em>support</em>=1.0) -> <em>self</em><br /> <span class="arg">img</span>.resize!(<span class= "arg">scale_factor</span>) -> <em>self</em></p> </div> <div class="desc"> <h4>Description</h4> <p>In-place form of <a href="#resize">resize</a>.</p> <h4>Returns</h4> <p>self</p> </div> <div class="sig"> <h3 id="resize_to_fill">resize_to_fill</h3> <p><span class="arg">img</span>.resize_to_fill(<span class= "arg">width</span> [, <span class="arg">height</span> [, <span class="arg">gravity</span>=<code>CenterGravity</code>]]) -> <span class="arg">image</span></p> </div> <div class="desc"> <h4>Description</h4> <p>A convenience method. Resize the image to fit within the specified dimensions while retaining the aspect ratio of the original image. If necessary, crop the image in the larger dimension.</p> <h4>Arguments</h4> <dl> <dt>width</dt> <dd>The width of the resulting image in pixels</dd> <dt>height</dt> <dd>(Optional) The height of the resulting image in pixels. If omitted, defaults to <span class="arg">width</span>.</dd> <dt>gravity</dt> <dd>Use this argument to specify which portion of the image to retain when cropping. The value can be any <a href= "constants.html#GravityType">GravityType</a> value. The effect is the same as the <span class="arg">gravity</span> argument to the <a href= "image1.html#crop"><code>crop</code></a> method. The default is <code>CenterGravity</code>.</dd> </dl> <h4>Returns</h4> <p>A new image</p> <h4>Example</h4> <p>In this example, some rows have been cropped from the top and bottom to produce a square thumbnail from a rectangular image without distorting the image.</p> <p class="rollover"><a href= "javascript:popup('resize_to_fill.rb.html')"> <!-- This img tag displays the original image when the mouse is over --> <img id="cropless" style="display: none" onmouseout= "this.style.display='none';cropped.style.display='';" src= "ex/images/Flower_Hat.jpg" alt="crop_resize example" title= "Click to see the example script" /> <!-- This img tag displays the framed image when the mouse is not over--> <img style= "padding-left:62px; padding-right: 62px; padding-top: 87px;padding-bottom:87px;" id="cropped" onmouseover= "this.style.display='none';cropless.style.display='';" src= "ex/resize_to_fill.jpg" alt="frame example" /></a> <img src= "ex/images/spin.gif" alt="" style="margin-bottom: 230px" title= "Mouse over the example to see the original image" /></p> <h4>See also</h4> <p><a href="image1.html#crop">crop</a>, <a href= "#resize">resize</a>, <a href= "#resize_to_fit">resize_to_fit</a></p> <h4>Notes</h4> <p><code>crop_resized</code> is an alias for this method.</p> </div> <div class="sig"> <h3 id="resize_to_fill_bang">resize_to_fill!</h3> <p><span class="arg">img</span>.resize_to_fill!(<span class= "arg">width</span> [, <span class="arg">height</span> [, <span class="arg">gravity</span>=<code>CenterGravity</code>]]) -> <em>self</em></p> </div> <div class="desc"> <h4>Description</h4>The in-place form of <a href= "#resize_to_fill">resize_to_fill</a>. <h4>Returns</h4> <p>self</p> <h4>See also</h4> <p><a href="image1.html#crop_bang">crop!</a>, <a href= "#resize_bang">resize!</a>, <a href= "#resize_to_fit_bang">resize_to_fit!</a></p> <h4>Notes</h4> <p><code>crop_resized!</code> is an alias for this method.</p> </div> <div class="sig"> <h3 id="resize_to_fit">resize_to_fit</h3> <p><span class="arg">img</span>.resize_to_fit(<span class= "arg">new_width</span> [, <span class="arg">new_height</span>]) -> <em>image</em></p> </div> <div class="desc"> <h4>Description</h4> <p>A convenience method. Resize the image to fit within the specified dimensions while retaining the original aspect ratio. The image may be shorter or narrower than specified in the smaller dimension but will not be larger than the specified values.</p> <h4>Arguments</h4> <dl> <dt>new_width</dt> <dd>The maximum width of the resized image.</dd> <dt>new_height</dt> <dd>(Optional) The maximum height of the resized image. If omitted it defaults to the value of <span class= "arg">new_width</span>.</dd> </dl> <h4>Returns</h4> <p>A new image</p> <h4>Example</h4> <p>Compare the result of this example to the result of the <a href="#resize_to_fill">resize_to_fill</a> example above.</p> <p class="rollover"><a href= "javascript:popup('resize_to_fit.rb.html')"> <!-- This img tag displays the original image when the mouse is over --> <img id="rtfless" style="display: none" onmouseout= "this.style.display='none';rtf.style.display='';" src= "ex/images/Flower_Hat.jpg" alt="resize_to_fill example" title= "Click to see the example script" /> <!-- This img tag displays the framed image when the mouse is not over--> <img style= "padding-left:69px; padding-right: 69px; padding-top: 87px;padding-bottom:87px;" id="rtf" onmouseover= "this.style.display='none';rtfless.style.display='';" src= "ex/resize_to_fit.jpg" alt="frame example" /></a> <img src= "ex/images/spin.gif" alt="" style="margin-bottom: 230px" title= "Mouse over the example to see the original image" /></p> <h4>See also</h4> <p><a href="#resize">resize</a>, <a href= "#resize_to_fill">resize_to_fill</a></p> </div> <div class="sig"> <h3 id="resize_to_fit_bang">resize_to_fit!</h3> <p><span class="arg">img</span>.resize_to_fit!(<span class= "arg">new_width</span> [, <span class="arg">new_height</span>]) -> <em>self</em></p> </div> <div class="desc"> <h4>Description</h4> <p>In-place form of <a href= "#resize_to_fit">resize_to_fit</a>.</p> <h4>Returns</h4> <p>self</p> <h4>See also</h4> <p><a href="#resize_bang">resize!</a>, <a href= "#resize_to_fill_bang">resize_to_fill!</a></p> </div> <div class="sig"> <h3 id="roll">roll</h3> <p><span class="arg">img</span>.roll(<span class= "arg">x_offset</span>, <span class="arg">y_offset</span>) -> <em>image</em></p> </div> <div class="desc"> <h4>Description</h4> <p class="imquote">Offsets an image as defined by <span class= "arg">x_offset</span> and <span class= "arg">y_offset</span>.</p> <h4>Arguments</h4> <dl> <dt>x_offset</dt> <dd>The number of columns to offset the image.</dd> <dt>y_offset</dt> <dd>The number of rows to offset the image.</dd> </dl> <h4>Returns</h4> <p>A new image</p> <h4>Example</h4> <p>This image has been offset 25% in both directions.</p> <p class="rollover"><a href= "javascript:popup('roll.rb.html')"><img src="ex/roll.jpg" title="Click to see the example script" alt="roll example" onmouseover="this.src='ex/images/Flower_Hat.jpg'" onmouseout= "this.src='ex/roll.jpg'" /></a><img src="ex/images/spin.gif" alt="" class="spin" title= "Mouse over the example to see the original image" /></p> <h4>Magick API</h4> <p>RollImage</p> </div> <div class="sig"> <h3 id="rotate">rotate</h3> <p><span class="arg">img</span>.rotate(<span class= "arg">amount</span> [, <span class="arg">qualifier</span>]) -> <em>image</em></p> </div> <div class="desc"> <h4>Description</h4> <p>Rotate the receiver by the specified angle. Positive angles rotate clockwise while negative angles rotate counter-clockwise. New pixels introduced by the rotation are the same color as the current <a href= "imageattrs.html#background_color">background color</a>. Set the background color to "none" to make the new pixels transparent black.</p> <h4>Arguments</h4> <dl> <dt>amount</dt> <dd>The number of degrees to rotate the image.</dd> <dt>qualifier</dt> <dd>If present, either ">" or "<". If ">", rotates the image only if the image's width exceeds its height. If "<" rotates the image only if its height exceeds its width. If this argument is omitted the image is always rotated.</dd> </dl> <h4>Returns</h4> <p>A new image, or <code>nil</code> if the image was not rotated because it did not meet the qualification specified by the second argument.</p> <h4>Example</h4> <p class="rollover"><a href= "javascript:popup('rotate_f.rb.html')"><!-- This img tag displays the original image when the mouse is over. Use CSS to add padding around the image to make it occupy the same space as the rotated image. --><img style="padding-top:34px;padding-bottom:34px; display:none" id="notrotated" onmouseout= "this.style.display='none'; rotated.style.display='';" src= "ex/images/Flower_Hat.jpg" alt="rotate example" title= "Click to see the example script" /><!-- This img tag displays the rotated image. --><img class="hide" id="rotated" onmouseover= "this.style.display='none'; notrotated.style.display='';" src= "ex/rotate_f.jpg" alt="rotate example" /></a> <img src= "ex/images/spin.gif" alt="" class="spin" style="left:322px;" title="Mouse over the example to see the original image" /></p> <h4>See also</h4> <p><a href="image1.html#affine_transform">affine_transform</a>, <a href="#shear">shear</a></p> <h4>Magick API</h4> <p>RotateImage</p> </div> <div class="sig"> <h3 id="rotate_bang">rotate!</h3> <p><span class="arg">img</span>.rotate!(<span class= "arg">amount</span> [, <span class="arg">qualifier</span>]) -> <em>self</em></p> </div> <div class="desc"> <h4>Description</h4> <p>In-place form of <a href="#rotate">rotate</a>.</p> <h4>Returns</h4> <p>self, or <code>nil</code> if the image was not rotated because it did not meet the qualification specified by the second argument.</p> </div> <div class="sig"> <h3 id="sample">sample</h3> <p><span class="arg">img</span>.sample(<span class= "arg">new_width</span>, <span class="arg">new_height</span>) -> <span class="arg">image</span><br /> <span class="arg">img</span>.sample(<span class= "arg">scale_factor</span>) -> <em>image</em></p> </div> <div class="desc"> <h4>Description</h4> <p>Scales an image to the desired dimensions with pixel sampling. Unlike other scaling methods, this method does not introduce any additional color into the scaled image.</p> <h4>Arguments</h4> <dl> <dt>new_width, new_height</dt> <dd>The desired width and height.</dd> <dt>scale_factor</dt> <dd>You can use this argument instead of specifying the desired width and height. The percentage size change. For example, 1.25 makes the new image 125% of the size of the receiver. The scale factor 0.5 makes the new image 50% of the size of the receiver.</dd> </dl> <h4>Returns</h4> <p>A new image</p> <h4>See also</h4> <p><a href="#sample_bang">sample!</a>, <a href= "image2.html#magnify">magnify</a>, <a href= "image2.html#minify">minify</a>, <a href="#resize">resize</a>, <a href="#scale">scale</a>, <a href= "#thumbnail">thumbnail</a></p> <h4>Magick API</h4> <p>SampleImage</p> </div> <div class="sig"> <h3 id="sample_bang">sample!</h3> <p><span class="arg">img</span>.sample!(<span class= "arg">new_width</span>, <span class="arg">new_height</span>) -> <em>self</em><br /> <span class="arg">img</span>.sample!(<span class= "arg">scale_factor</span>) -> <em>self</em></p> </div> <div class="desc"> <h4>Description</h4> <p>In-place form of <a href="#sample">sample</a>.</p> <h4>Returns</h4> <p>self</p> </div> <div class="sig"> <h3 id="scale">scale</h3> <p><span class="arg">img</span>.scale(<span class= "arg">new_width</span>, <span class="arg">new_height</span>) -> <em>image</em><br /> <span class="arg">img</span>.scale(<span class= "arg">scale_factor</span>) -> <em>image</em></p> </div> <div class="desc"> <h4>Description</h4> <p class="imquote">Changes the size of an image to the given dimensions.</p> <h4>Arguments</h4> <dl> <dt>new_width, new_height</dt> <dd>The desired width and height.</dd> <dt>scale_factor</dt> <dd>You can use this argument instead of specifying the desired width and height. The percentage size change. For example, 1.25 makes the new image 125% of the size of the receiver. The scale factor 0.5 makes the new image 50% of the size of the receiver.</dd> </dl> <h4>Returns</h4> <p>A new image</p> <h4>See also</h4> <p><a href="#scale_bang">scale!</a>, <a href= "image2.html#magnify">magnify</a>, <a href= "image2.html#minify">minify</a>, <a href="#resize">resize</a>, <a href="#sample">sample</a>, <a href= "#thumbnail">thumbnail</a></p> <h4>Magick API</h4> <p>ScaleImage</p> </div> <div class="sig"> <h3 id="scale_bang">scale!</h3> <p><span class="arg">img</span>.scale!(<span class= "arg">new_width</span>, <span class="arg">new_height</span>) -> <em>self</em><br /> <span class="arg">img</span>.scale!(<span class= "arg">scale_factor</span>) -> <em>self</em></p> </div> <div class="desc"> <h4>Description</h4> <p>In-place form of <a href="#scale">scale</a>.</p> <h4>Returns</h4> <p>self</p> </div> <div class="sig"> <h3 id="segment">segment</h3> <p><span class="arg">img</span>.segment(<span class= "arg">colorspace</span>=RGBColorspace, <span class= "arg">cluster_threshold</span>=1.0, <span class= "arg">smoothing_threshold</span>=1.5, <span class= "arg">verbose</span>=<code>false</code>) -> <em>image</em></p> </div> <div class="desc"> <h4>Description</h4> <p class="imquote">Segments an image by analyzing the histograms of the color components and identifying units that are homogeneous with the fuzzy c-means technique.</p> <h4>Arguments</h4> <dl> <dt>colorspace</dt> <dd>A <a href= "constants.html#ColorspaceType"><code>ColorspaceType</code></a> value. <span class="imquote">Empirical evidence suggests that distances in YUV or YIQ correspond to perceptual color differences more closely than do distances in RGB space. The image is then returned to RGB colorspace after color reduction.</span></dd> <dt>cluster_threshold</dt> <dd class="imquote">The number of pixels in each cluster must exceed the the cluster threshold to be considered valid.</dd> <dt>smoothing_threshold</dt> <dd>The <span class="imquote">smoothing threshold eliminates noise in the second derivative of the histogram. As the value is increased, you can expect a smoother second derivative.</span></dd> <dt>verbose</dt> <dd>If <code>true</code>, <code>segment</code> prints detailed information about the identified classes.</dd> </dl> <h4>Returns</h4> <p>A new image</p> <h4>Example</h4> <p><code>segment(YUVColorspace, 0.4, 0.4)</code></p> <p class="rollover"><a href= "javascript:popup('segment.rb.html')"><img src="ex/segment.jpg" alt="segment example" title="Click to see the example script" onmouseover="this.src='ex/images/Flower_Hat.jpg'" onmouseout= "this.src='ex/segment.jpg'" /></a> <img src= "ex/images/spin.gif" alt="" class="spin" title= "Mouse over the example to see the original image" /></p> <h4>Magick API</h4> <p>SegmentImage</p> </div> <div class="sig"> <h3 id="separate">separate</h3> <p>Image.separate(<span class="arg">channel</span>...) -> <span class="arg">imagelist</span></p> </div> <div class="desc"> <h4>Description</h4> <p>Constructs a grayscale image for each channel specified.</p> <h4>Arguments</h4> <p>0 or more <a href= "constants.html#ChannelType">ChannelType</a> arguments. If no channels are specified, constructs an image for each of the red, green, and blue channels.</p> <h4>Returns</h4> <p>A new imagelist containing the new images.</p> <h4>See also</h4> <p><a href="image1.html#channel">channel</a></p> <h4>Notes</h4> <p>If the image does not have an opacity channel an OpacityChannel argument is ignored.</p> <h4>Magick API</h4> <p>SeparateImages</p> </div> <div class="sig"> <h3 id="sepiatone">sepiatone</h3> <p><span class="arg">img</span>.sepiatone(<span class= "arg">threshold</span>=QuantumRange) -> <span class= "arg">image</span></p> </div> <div class="desc"> <h4>Description</h4> <p class="imquote">Applies a special effect to the image, similar to the effect achieved in a photo darkroom by sepia toning.</p> <h4>Arguments</h4> <dl> <dt>threshold</dt> <dd class="imquote"><span class="arg">Threshold</span> ranges from 0 to QuantumRange and is a measure of the extent of the sepia toning. A threshold of 80% is a good starting point for a reasonable tone. The default is QuantumRange.</dd> </dl> <h4>Returns</h4> <p>A new image.</p> <h4>Example</h4> <p class="rollover"><a href= "javascript:popup('sepiatone.rb.html')"><img src= "ex/sepiatone.jpg" alt="sepiatone example" onmouseover= "this.src='ex/images/Flower_Hat.jpg'" onmouseout= "this.src='ex/sepiatone.jpg'" title= "Click to see the example script" /></a> <img src= "ex/images/spin.gif" alt="" class="spin" title= "Mouse over the example to see the original image" /></p> <h4>See also</h4> <p>You can get more control by using <a href= "image1.html#colorize">colorize</a>.</p> <h4>Magick API</h4> <p>SepiaToneImage</p> </div> <div class="sig"> <h3 id="set_channel_depth">set_channel_depth</h3> <p><span class="arg">img.</span>set_channel_depth(<span class= "arg">channel</span>, <span class="arg">depth</span>) -> <em>self</em></p> </div> <div class="desc"> <h4>Description</h4> <p>Sets the depth of the image channel.</p> <h4>Arguments</h4> <dl> <dt>channel</dt> <dd>A <a href="constants.html#ChannelType">ChannelType</a> value</dd> <dt>depth</dt> <dd>The desired depth (must be no greater than <a href= "constants.html">QuantumDepth</a>)</dd> </dl> <h4>Returns</h4> <p>self</p> <h4>See also</h4> <p><a href="image1.html#channel_depth">channel_depth</a></p> <h4>Magick API</h4> <p>SetImageChannelDepth</p> </div> <div class="sig"> <h3 id="shade">shade</h3> <p><span class="arg">img</span>.shade(<span class= "arg">shading</span>=<code>false</code>, <span class= "arg">azimuth</span>=30, <span class="arg">elevation</span>=30) -> <em>image</em></p> </div> <div class="desc"> <h4>Description</h4> <p class="imquote">Shines a distant light on an image to create a three-dimensional effect. You control the positioning of the light with <span class="arg">azimuth</span> and <span class= "arg">elevation</span>; <span class="arg">azimuth</span> is measured in degrees off the x axis and <span class= "arg">elevation</span> is measured in pixels above the Z axis.</p> <h4>Arguments</h4> <dl> <dt>shading</dt> <dd>If <code>true</code>, <code>shade</code> shades the intensity of each pixel.</dd> <dt>azimuth, elevation</dt> <dd>The light source direction. The azimuth is measured in degrees. 0° is at 9 o'clock. Increasing values move the light source counter-clockwise.</dd> </dl> <h4>Returns</h4> <p>A new image</p> <h4>Example</h4> <p><code>shade(true, 50, 50)</code></p> <p class="rollover"><a href= "javascript:popup('shade.rb.html')"><img src="ex/shade.jpg" alt="shade example" onmouseover= "this.src='ex/images/Flower_Hat.jpg'" onmouseout= "this.src='ex/shade.jpg'" title= "Click to see the example script" /></a> <img src= "ex/images/spin.gif" alt="" class="spin" title= "Mouse over the example to see the original image" /></p> <h4>Magick API</h4> <p>ShadeImage</p> </div> <div class="sig"> <h3 id="shadow">shadow</h3> <p><span class="arg">img</span>.shadow(<span class= "arg">x_offset=4</span>, <span class="arg">y_offset=4</span>, <span class="arg">sigma=4.0</span>, <span class= "arg">opacity=1.0</span>) -> <em>image</em></p> </div> <div class="desc"> <h4>Description</h4>Draws the shadow of opaque parts of the image. This method only works when the image has opaque parts and transparent parts. Note that the resulting image is just the shadow. You must composite the original image over the shadow to produce the shadowed results. <h4>Arguments</h4> <dl> <dt>x_offset</dt> <dd>The shadow x-offset</dd> <dt>y_offset</dt> <dd>The shadow y-offset</dd> <dt>sigma</dt> <dd>The standard deviation of the Gaussian operator used to produce the shadow. The higher the number, the "blurrier" the shadow, but the longer it takes to produce the shadow. Must be > 0.0.</dd> <dt>opacity</dt> <dd>The percent opacity of the shadow. May be either a number between 0.1 and 1.0, or a string in the form "NN%" between "1%" and "100%". If the percentage is greater than 100 it is reduced to 100.</dd> </dl> <h4>Returns</h4> <p>A new image</p> <h4>Example</h4> <p class="rollover"><a href= "javascript:popup('shadow.rb.html')"> <!-- This img tag displays the original image when the mouse is over --> <img style="padding:8px; display:none" id="shadowless" onmouseout= "this.style.display='none';shadowed.style.display='';" src= "ex/shadow_before.gif" alt="shadow example" title= "Click to see the example script" /><!-- This img tag displays the shadowed image when the mouse is not over --><img class="hide" id="shadowed" onmouseover= "this.style.display='none';shadowless.style.display='';" src= "ex/shadow_after.gif" alt="shadow example" /></a> <img src= "ex/images/spin.gif" alt="" style="margin-bottom: 120px" title= "Mouse over the example to see the original image" /></p> <h4>Magick API</h4> <p>ShadowImage</p> <h4>Notes</h4> <p>The shadow image is 2×<span class="arg">sigma</span> pixels larger on a side than the original image, as can be seen in the example above.</p> </div> <div class="sig"> <h3 id="sharpen">sharpen</h3> <p><span class="arg">img</span>.sharpen(<span class= "arg">radius</span>=0.0, <span class="arg">sigma</span>=1.0) -> <em>image</em></p> </div> <div class="desc"> <h4>Description</h4> <p class="imquote">Sharpens an image. We convolve the image with a Gaussian operator of the given <span class= "arg">radius</span> and standard deviation (<span class= "arg">sigma</span>). For reasonable results, <span class= "arg">radius</span> should be larger than <span class= "arg">sigma</span>. Use a radius of 0 and <code>sharpen</code> selects a suitable radius for you.</p> <h4>Arguments</h4> <p>The radius and standard deviation of the Gaussian operator.</p> <h4>Returns</h4> <p>A new image</p> <h4>Magick API</h4> <p>SharpenImage</p> <h4>See also</h4> <p><a href= "imageattrs.html#virtual_pixel_method">virtual_pixel_method</a></p> </div> <div class="sig"> <h3 id="sharpen_channel">sharpen_channel</h3> <p><span class="arg">img</span>.sharpen_channel( <span class= "arg">radius</span>, <span class="arg">sigma</span> [,<span class="arg">channel</span>...] ) -> <em>image</em></p> </div> <div class="desc"> <h4>Description</h4> <p class="imquote">Sharpens one or more image channels. We convolve the image with a Gaussian operator of the given radius and standard deviation (<span class="arg">sigma</span>) . For reasonable results, <span class="arg">radius</span> should be larger than <span class="arg">sigma</span>. Use a radius of 0 and <code>sharpen_channel</code> selects a suitable radius for you.</p> <h4>Arguments</h4> <dl> <dt>radius, sigma</dt> <dd>The radius and standard deviation of the Gaussian operator.</dd> <dt>channel...</dt> <dd>0 or more <a href= "constants.html#ChannelType">ChannelType</a> arguments. If no channels are specified, all the channels are sharpened.</dd> </dl> <h4>Returns</h4> <p>A new image</p> <h4>See also</h4> <p><a href="#sharpen">sharpen</a></p> <h4>Magick API</h4> <p>SharpenImageChannel</p> </div> <div class="sig"> <h3 id="shave">shave</h3> <p><span class="arg">img</span>.shave(<span class= "arg">width</span>, <span class="arg">height</span>) -> <em>image</em></p> </div> <div class="desc"> <h4>Description</h4> <p>Removes pixels from the edges of the image, leaving the center rectangle.</p> <h4>Arguments</h4> <dl> <dt>width</dt> <dd>The number of pixels to remove from each side of the receiver, not to exceed half the original width.</dd> <dt>height</dt> <dd>The number of pixels to remove from the top and bottom of the receiver, not to exceed half the original height.</dd> </dl> <h4>Returns</h4> <p>A new image</p> <h4>Example</h4> <p class="rollover"><a href= "javascript:popup('shave.rb.html')"><img src="ex/shave.jpg" onmouseover="this.src='ex/images/Flower_Hat.jpg'" onmouseout= "this.src='ex/shave.jpg'" alt="shave example" title= "Click to see the example script" /></a> <img src= "ex/images/spin.gif" alt="" class="spin" title= "Mouse over the example to see the original image" /></p> <h4>See also</h4> <p><a href="#shave_bang">shave!</a>, <a href= "image1.html#crop">crop</a></p> <h4>Magick API</h4> <p>ShaveImage</p> </div> <div class="sig"> <h3 id="shave_bang">shave!</h3> <p><span class="arg">img</span>.shave!(<span class= "arg">width</span>, <span class="arg">height</span>) -> <em>self</em></p> </div> <div class="desc"> <h4>Description</h4> <p>In-place form of <a href="#shave">shave</a>.</p> <h4>Returns</h4> <p>self</p> </div> <div class="sig"> <h3 id="shear">shear</h3> <p><span class="arg">img</span>.shear(<span class= "arg">x_shear</span>, <span class="arg">y_shear</span>) -> <em>image</em></p> </div> <div class="desc"> <h4>Description</h4> <p class="imquote">Shearing slides one edge of an image along the X or Y axis, creating a parallelogram. An X direction shear slides an edge along the X axis, while a Y direction shear slides an edge along the Y axis. The amount of the shear is controlled by a shear angle. For X direction shears, <span class="arg">x_shear</span> is measured relative to the Y axis, and similarly, for Y direction shears <span class= "arg">y_shear</span> is measured relative to the X axis. Empty triangles left over from shearing the image are filled with the background color.</p> <h4>Arguments</h4> <p>The X and Y shear angles, measured in degrees. These values must not be 180.0. If either value is 0, no shearing will occur.</p> <h4>Returns</h4> <p>A new image</p> <h4>Example</h4> <p class="rollover"><a href= "javascript:popup('shear.rb.html')"><!-- This img tag displays the original image when the mouse is over --><img style="padding-top:34px; padding-bottom:33px; padding-left:49px; padding-right:49px; display:none" id="noshear" onmouseout= "this.style.display='none'; sheared.style.display='';" src= "ex/images/Flower_Hat.jpg" alt="shear example" title= "Click to see the example script" /> <!-- This img tag displays the sheared image when the mouse is not over --> <img id="sheared" onmouseover= "this.style.display='none'; noshear.style.display='';" src= "ex/shear.jpg" alt="shear example" /></a><img src= "ex/images/spin.gif" alt="" class="spin" style= "left: 253px; top: 34px" title= "Mouse over the example to see the original image" /></p> <h4>See also</h4> <p><a href="image1.html#affine_transform">affine_transform</a>, <a href="#rotate">rotate</a></p> <h4>Magick API</h4> <p>ShearImage</p> </div> <div class="sig"> <h3 id="sigmoidal_contrast_channel"> sigmoidal_contrast_channel</h3> <p><br /> <span class= "arg">img</span>.sigmoidal_contrast_channel(<span class= "arg">contrast</span>=3.0, <span class= "arg">midpoint</span>=50.0, <span class= "arg">sharpen</span>=false[,<span class= "arg">channel</span>...]) -> <em>image</em></p> </div> <div class="desc"> <h4>Description</h4> <p class="imquote">Adjusts the contrast of an image channel with a non-linear sigmoidal contrast algorithm. Increases the contrast of the image using a sigmoidal transfer function without saturating highlights or shadows.</p> <h4>Arguments</h4> <dl> <dt>contrast</dt> <dd class="imquote">indicates how much to increase the contrast (0 is none; 3 is typical; 20 is pushing it)</dd> <dt>midpoint</dt> <dd class="imquote">indicates where midtones fall in the resultant image (0 is white; 50% is middle-gray; 100% is black)</dd> <dt>sharpen</dt> <dd class="imquote">Set <span class="arg">sharpen</span> to <code>true</code> to increase the image contrast otherwise the contrast is reduced.</dd> <dt>channel...</dt> <dd>0 or more <a href= "constants.html#ChannelType">ChannelType</a> arguments. If no channels are specified, all the channels are adjusted.</dd> </dl> <h4>Returns</h4> <p>A new image</p> <h4>See also</h4> <p><a href="image1.html#contrast">contrast</a></p> <h4>Magick API</h4> <p>SigmoidalContrastImageChannel</p> </div> <div class="sig"> <h3 id="signature">signature</h3> <p><span class="arg">img</span>.signature -> <em>string</em></p> </div> <div class="desc"> <h4>Description</h4> <p class="imquote">Computes a message digest from an image pixel stream with an implementation of the NIST SHA-256 Message Digest algorithm. This signature uniquely identifies the image and is convenient for determining if an image has been modified or whether two images are identical.</p> <p>ImageMagick adds the computed signature to the image's properties.</p> <h4>Returns</h4> <p>The signature as a 64-character string.</p> <h4>Example</h4> <pre> img = Image.read('ex/images/Flower_Hat.jpg').first » ex/images/Flower_Hat.jpg JPEG 200x250 DirectClass 8-bit 9761b img.properties » {"comment"=>"File written by Adobe Photoshop\250 4.0"} img.signature » "485e01ecba1a1f47924d67b887cb07b474f695841733796dfa3c2876965c7e8b" img.properties » {"signature"=>"485e01ecba1a1f47924d67b887cb07b474f695841733796dfa3c2876965c7e8b", "comment"=>"File written by Adobe Photoshop\250 4.0"} </pre> <h4>See also</h4> <p><a href="image1.html#spaceship"><=></a>, <a href= "image1.html#difference">difference</a></p> <h4>Magick API</h4> <p>SignatureImage</p> </div> <div class="sig"> <h3 id="sketch">sketch</h3> <p><span class="arg">img</span>.sketch(<span class= "arg">radius</span>=0.0, <span class="arg">sigma</span>=1.0, <span class="arg">angle</span>=0.0) -> <em>image</em></p> </div> <div class="desc"> <h4>Description</h4> <p>Simulates a pencil sketch. For best results start with a grayscale image.</p> <h4>Arguments</h4> <dl> <dt>radius, sigma</dt> <dd>The radius and sigma of the Gaussian operator</dd> <dt>angle</dt> <dd>The angle toward which the image is sketched.</dd> </dl> <h4>Returns</h4> <p>A new image</p> <h4>Example</h4> <p class="rollover"><a href= "javascript:popup('sketch.rb.html')"><img src="ex/sketch.jpg" title="Click to see the example script" alt="sketch example" onmouseover="this.src='ex/images/Flower_Hat.jpg'" onmouseout= "this.src='ex/sketch.jpg'" /></a> <img src="ex/images/spin.gif" alt="" class="spin" title= "Mouse over the example to see the original image" /></p> <h4>Magick API</h4> <p>SketchImage</p> </div> <div class="sig"> <h3 id="solarize">solarize</h3> <p><span class="arg">img</span>.solarize(<span class= "arg">threshold</span>=50) -> <em>image</em></p> </div> <div class="desc"> <h4>Description</h4> <p class="imquote">Applies a special effect to the image similar to the effect achieved in a photo darkroom by selectively exposing areas of photo sensitive paper to light.</p> <h4>Arguments</h4> <p><span class="imquote">Ranges from 0 to QuantumRange and is a measure of the extent of the solarization.</span> The default is 50.</p> <h4>Returns</h4> <p>A new image</p> <h4>Example</h4> <p class="rollover"><a href= "javascript:popup('solarize.rb.html')"><img src= "ex/solarize.jpg" title="Click to see the example script" alt= "solarize example" onmouseover= "this.src='ex/images/Flower_Hat.jpg'" onmouseout= "this.src='ex/solarize.jpg'" /></a> <img src= "ex/images/spin.gif" alt="" class="spin" title= "Mouse over the example to see the original image" /></p> <h4>Magick API</h4> <p>SolarizeImage</p> </div> <div class="sig"> <h3 id="splice">splice</h3> <p><span class="arg">img</span>.splice(<span class= "arg">x</span>, <span class="arg">y</span>, <span class= "arg">width</span>, <span class="arg">height</span>[, <span class="arg">color</span>]) -> <em>image</em></p> </div> <div class="desc"> <h4>Description</h4> <p>Splice a solid color into the image as defined by the <code>x</code>, <code>y</code>, <code>width</code>, and <code>height</code> arguments. This method is the opposite of <a href="image1.html#chop">chop</a>.</p> <h4>Arguments</h4> <dl> <dt>x, y, width, height</dt> <dd>Describe the rectangle to be spliced.</dd> <dt>color</dt> <dd>The color to be spliced. Either a <a href= "imusage.html#color_names">color name</a> or a <a href= "struct.html#Pixel">pixel</a>. If omitted, uses the image's background color.</dd> </dl> <h4>Returns</h4> <p>A new image</p> <h4>Example</h4> <p class="rollover"><a href= "javascript:popup('splice.rb.html')"> <!-- This img tag displays the original image when the mouse is over --> <img style= "padding-left:8px;padding-right:8px;padding-bottom:10px;padding-bottom:10px; display:none" id="nosplice" onmouseout= "this.style.display='none';spliced.style.display='';" src= "ex/images/Flower_Hat.jpg" alt="splice example" title= "Click to see the example script" /><!-- This img tag displays the spliced image when the mouse is not over --><img class="hide" id="spliced" onmouseover= "this.style.display='none';nosplice.style.display='';" src= "ex/splice.jpg" alt="splice example" /></a> <img src= "ex/images/spin.gif" alt="" style="margin-bottom: 280px" title= "Mouse over the example to see the original image" /></p> <h4>See also</h4> <p><a href= "image1.html#color_fill_to_border">color_fill_to_border</a>, <a href="image1.html#color_floodfill">color_floodfill</a>, <a href="image1.html#color_reset_bang">color_reset!</a>, <a href="image2.html#erase_bang">erase!</a>, <a href= "image2.html#opaque">opaque</a></p> <h4>Magick API</h4> <p>SpliceImage</p> </div> <div class="sig"> <h3 id="spread">spread</h3> <p><span class="arg">img</span>.spread(<span class= "arg">radius</span>=3) -> <em>image</em></p> </div> <div class="desc"> <h4>Description</h4> <p class="imquote">Randomly displaces each pixel in a block defined by the <span class="arg"><em>radius</em></span> parameter.</p> <h4>Returns</h4> <p>A new image</p> <h4>Example</h4> <p class="rollover"><a href= "javascript:popup('spread.rb.html')"><img src="ex/spread.jpg" alt="spread example" title="Click to see the example script" onmouseover="this.src='ex/images/Flower_Hat.jpg'" onmouseout= "this.src='ex/spread.jpg'" /></a> <img src="ex/images/spin.gif" alt="" class="spin" title= "Mouse over the example to see the original image" /></p> <h4>Magick API</h4> <p>SpreadImage</p> </div> <div class="sig"> <h3 id="stegano">stegano</h3> <p><span class="arg">img</span>.stegano(<span class= "arg">watermark</span>, <span class="arg">offset</span>) -> <em>image</em></p> </div> <div class="desc"> <h4>Description</h4> <p>Hides a digital watermark in the receiver. You can retrieve the watermark by reading the file with the <code>stegano:</code> prefix, thereby proving the authenticity of the file.</p> <p>The watermarked image must be saved in a lossless RGB format such as MIFF, or PNG. You cannot save a watermarked image in a lossy format such as JPEG or a pseudocolor format such as GIF. Once written, the file must not be modified or processed in any way.</p> <h4>Arguments</h4> <dl> <dt>watermark</dt> <dd>An image or imagelist to be used as the watermark. The watermark must be grayscale and should be substantially smaller than the receiver. The recovery time is proportional to the size of the watermark.</dd> <dt>offset</dt> <dd>The starting position within the receiver at which the watermark will be hidden. When you retrieve the watermark from the file, you must supply this value, along with the width and height of the watermark, in the <a href= "info.html#Info.size_eq">size</a> optional parameter to the <a href="image1.html#read">read</a> method.</dd> </dl> <h4>Returns</h4> <p>A copy of the image containing the embedded watermark.</p> <h4>Example</h4> <p><a href="javascript:popup('stegano.rb.html')"><img src= "ex/stegano.gif" title="Click to see the example script" alt= "stegano example" /></a></p> <h4>Magick API</h4> <p>SteganoImage</p> <h4>See also</h4> <p><a href="#watermark">watermark</a></p> </div> <div class="sig"> <h3 id="stereo">stereo</h3> <p><span class="arg">img</span>.stereo(<span class= "arg">offset_image</span>) -> <em>image</em></p> </div> <div class="desc"> <h4>Description</h4> <p class="imquote">Combines two images and produces a single image that is the composite of a left and right image of a stereo pair. Special red-green stereo glasses are required to view this effect.</p> <h4>Arguments</h4> <p>Another image or imagelist. If the argument is an imagelist, uses the current image.</p> <h4>Returns</h4> <p>A new image</p> <h4>Magick API</h4> <p>StereoImage</p> </div> <div class="sig"> <h3 id="store_pixels">store_pixels</h3> <p><span class="arg">img</span>.store_pixels(<span class= "arg">x</span>, <span class="arg">y</span>, <span class= "arg">columns</span>, <span class="arg">rows</span>, <span class="arg">pixels</span>) -> <em>image</em></p> </div> <div class="desc"> <h4>Description</h4> <p>Replace the pixels in the specified rectangle with the pixels in the <em>pixels</em> array.</p> <h4>Arguments</h4> <dl> <dt>x, y</dt> <dd>The x- and y-offset of the rectangle to be replaced.</dd> <dt>columns, rows</dt> <dd>The number of rows and columns in the rectangle.</dd> <dt>pixels</dt> <dd>An array of <a href="struct.html#Pixel">pixels</a>. The number of pixels in the array must be the same as the number of pixels in the rectangle, that is, <code>rows*columns</code>.</dd> </dl> <h4>Returns</h4> <p>The image, with the rectangle suitably altered.</p> <h4>Example</h4> <p><a href="javascript:popup('smile.rb.html')"><img src= "ex/smile.gif" title="Click to see the example script" alt= "smile example" /></a></p> <p>Also see the example for <a href= "image2.html#get_pixels"><code>get_pixels</code></a>.</p> <h4>See also</h4> <p><a href="image1.html#constitute">constitute</a>, <a href= "image2.html#get_pixels">get_pixels</a>, <a href= "#view">view</a></p> <h4>Magick API</h4> <p>SetImagePixels, SyncImagePixels</p> </div> <div class="sig"> <h3 id="strip_bang">strip!</h3> <p><span class="arg">img</span>.strip! -> <em>self</em></p> </div> <div class="desc"> <h4>Description</h4> <p class="imquote">Strips an image of all profiles and comments.</p> <h4>Returns</h4> <p>self</p> <h4>Magick API</h4> <p>StripImage</p> </div> <div class="sig"> <h3 id="swirl">swirl</h3> <p><span class="arg">img</span>.swirl(<span class= "arg">degrees</span>) -> <em>image</em></p> </div> <div class="desc"> <h4>Description</h4> <p class="imquote">Swirls the pixels about the center of the image, where degrees indicates the sweep of the arc through which each pixel is moved. You get a more dramatic effect as the degrees move from 1 to 360.</p> <h4>Arguments</h4> <p>The number of degrees to swirl the image.</p> <h4>Returns</h4> <p>A new image</p> <h4>Example</h4> <p>This example is an animated image. Mouse over the image to start the animation.</p> <p class="rollover"><a href= "javascript:popup('swirl.rb.html')"><img onmouseover= "this.src='ex/swirl.gif'" onmouseout= "this.src='ex/images/Flower_Hat.jpg'" src= "ex/images/Flower_Hat.jpg" alt="swirl example" title= "Click the image to see the example script" /></a><img src= "ex/images/spin.gif" alt="" class="spin" title= "Mouse over the example to see the animation" /></p> <h4>Magick API</h4> <p>SwirlImage</p> </div> <div class="sig"> <h3 id="sync_profiles">sync_profiles</h3> <p><span class="arg">img</span>.sync_profiles -> <code>true</code> or <code>false</code></p> </div> <div class="desc"> <h4>Description</h4> <p class="imquote">Synchronizes image properties with the image profiles.</p> <h4>Returns</h4> <p><code>True</code> if everything went okay, <code>false</code> if there was a problem with the profile.</p> <h4>Notes</h4> <p class="imquote">Currently we only support updating the EXIF resolution and orientation.</p> <h4>Magick API</h4> <p>SyncImageProfiles</p> </div> <div class="sig"> <h3 id="texture_fill_to_border">texture_fill_to_border</h3> <p><span class= "arg">img</span>.texture_fill_to_border(<span class= "arg">x</span>, <span class="arg">y</span>, <span class= "arg">texture</span>) -> <em>image</em></p> </div> <div class="desc"> <h4>Description</h4> <p>Replaces the target pixel at <span class="arg">x</span>, <span class="arg">y</span> and its neighbors that are not the border color with copies of the <span class= "arg">texture</span> image. Use the <a href= "imageattrs.html#fuzz">fuzz</a> attribute to specify how closely a pixel must match the border color.</p> <h4>Arguments</h4> <dl> <dt>x, y</dt> <dd>The x- and y-offset of the target pixel.</dd> <dt>texture</dt> <dd>An image or imagelist. If an imagelist, uses the current image.</dd> </dl> <h4>Returns</h4> <p>A new image</p> <h4>Example</h4> <p>In this example the target is the pixel in the center of the image. The texture - in this case a picture of a girl in a flowered hat - replaces this pixel and its neighbors until reaching a black pixel. Mouse over the image to see the original image. Notice the plum-colored circles are replaced as well. Compare this result with the result of <code>texture_floodfill</code>, below.</p> <p class="rollover"><a href= "javascript:popup('texture_fill_to_border.rb.html')"><img src= "ex/texture_fill_to_border_after.gif" alt= "texture_fill_to_border example" onmouseover= "this.src='ex/texture_fill_to_border_before.gif'" onmouseout= "this.src='ex/texture_fill_to_border_after.gif'" title= "Click to see the example script" /></a> <img src= "ex/images/spin.gif" alt="" class="spin" style="left:206px;" title="Mouse over the example to see the original image" /></p> <h4>See also</h4> <p><a href= "image1.html#color_fill_to_border">color_fill_to_border</a>, <a href= "image2.html#matte_fill_to_border">matte_fill_to_border</a></p> <h4>Magick API</h4> <p>ColorFloodfillImage</p> </div> <div class="sig"> <h3 id="texture_floodfill">texture_floodfill</h3> <p><span class="arg">img</span>.texture_floodfill(<span class= "arg">x</span>, <span class="arg">y</span>, <span class= "arg">texture</span>) -> <em>image</em></p> </div> <div class="desc"> <h4>Description</h4> <p>Replaces the target pixel at <span class="arg">x</span>, <span class="arg">y</span> and its neighbors that are the same color with the <span class="arg">texture</span> image. By default, the neighbor pixels must be exactly the same color as the target pixel. Use the <a href= "imageattrs.html#fuzz">fuzz</a> attribute to specify how much difference is acceptable.</p> <h4>Arguments</h4> <dl> <dt>x, y</dt> <dd>The x- and y-offset of the target pixel.</dd> <dt>texture</dt> <dd>An image or imagelist. If an imagelist, uses the current image.</dd> </dl> <h4>Returns</h4> <p>A new image</p> <h4>Example</h4> <p>In this example the target is the pixel in the center of the image. The texture - in this case a picture of a girl in a flowered hat - replaces this pixel and its same-colored neighbors. Mouse over the image to see the original image. Notice the plum-colored circles are not replaced. Compare this result with the result of <code>texture_fill_to_border</code>, above.</p> <p class="rollover"><a href= "javascript:popup('texture_floodfill.rb.html')"><img src= "ex/texture_floodfill_after.gif" alt= "texture_floodfill example" onmouseover= "this.src='ex/texture_floodfill_before.gif'" onmouseout= "this.src='ex/texture_floodfill_after.gif'" title= "Click to see the example script" /></a><img src= "ex/images/spin.gif" alt="" class="spin" style="left:206px;" title="Mouse over the example to see the original image" /></p> <h4>See also</h4> <p><a href="image1.html#color_floodfill">color_floodfill</a>, <a href="image2.html#matte_floodfill">matte_floodfill</a></p> <h4>Magick API</h4> <p>ColorFloodfillImage</p> </div> <div class="sig"> <h3 id="threshold">threshold</h3> <p><span class="arg">img</span>.threshold(<span class= "arg">threshold</span>) -> <em>image</em></p> </div> <div class="desc"> <h4>Description</h4> <p class="imquote">Changes the value of individual pixels based on the intensity of each pixel compared to <span class= "arg">threshold</span>. The result is a high-contrast, two color image.</p> <h4>Arguments</h4> <p>A value between 0 and QuantumRange.</p> <h4>Returns</h4> <p>A new image</p> <h4>Example</h4> <p><code>threshold(MaxRGB*0.55)</code></p> <p class="rollover"><a href= "javascript:popup('threshold.rb.html')"><img src= "ex/threshold.jpg" onmouseover= "this.src='ex/images/Flower_Hat.jpg'" onmouseout= "this.src='ex/threshold.jpg'" title= "Click to see the example script" alt= "threshold example" /></a><img src="ex/images/spin.gif" alt="" class="spin" title= "Mouse over the example to see the original image" /></p> <h4>See also</h4> <p><a href= "image1.html#adaptive_threshold">adaptive_threshold</a>, <a href="image1.html#bilevel_channel">bilevel_channel</a>, <a href= "#random_threshold_channel">random_threshold_channel</a></p> <h4>Magick API</h4> <p>ThresholdImage</p> </div> <div class="sig"> <h3 id="thumbnail">thumbnail</h3> <p><span class="arg">img</span>.thumbnail(<span class= "arg">new_width</span>, <span class="arg">new_height</span>) -> <em>image</em><br /> <span class="arg">img</span>.thumbnail(<span class= "arg">scale_factor</span>) -> <em>image</em></p> </div> <div class="desc"> <h4>Description</h4> <p>The <code>thumbnail</code> method is a fast resizing method suitable for use when the size of the resulting image is < 10% of the original.</p> <h4>Arguments</h4> <p>You can call <code>thumbnail</code> with either the new width and height or the scale factor.</p> <dl> <dt>new_width, new_height</dt> <dd>The desired width and height in pixels.</dd> <dt>scale_factor</dt> <dd>The desired size represented as a floating-point number. For example, to make a thumbnail that is 9.5% of the size of the original image, use <code>0.095</code>.</dd> </dl> <h4>Returns</h4> <p>A new image</p> <h4>Example</h4> <pre> img = Image.read("images/Cheetah.jpg").first thumbnail = img.thumbnail(img.columns*0.09, img.rows*0.09) </pre> <h4>See also</h4> <p><a href="image2.html#minify">minify</a>, <a href= "#resize">resize</a>, <a href="#sample">sample</a>, <a href= "#scale">scale</a></p> <h4>Magick API</h4> <p>ThumbnailImage</p> </div> <div class="sig"> <h3 id="thumbnail_bang">thumbnail!</h3> <p><span class="arg">img</span>.thumbnail!(<span class= "arg">new_width</span>, <span class="arg">new_height</span>) -> <em>self</em><br /> <span class="arg">img</span>.thumbnail!(<span class= "arg">scale_factor</span>) -> <em>self</em></p> </div> <div class="desc"> <h4>Description</h4> <p>In-place form of <a href="#thumbnail">thumbnail</a>.</p> <h4>Returns</h4> <p>self</p> </div> <div class="sig"> <h3 id="to_blob">to_blob</h3> <p><span class="arg">img</span>.to_blob <span class="arg">[ { optional arguments } ]</span>-> <em>string</em></p> </div> <div class="desc"> <h4>Description</h4> <p>Creates a <em>B</em>inary <em>L</em>arge <em>OB</em>ject, a direct-to-memory version of the image. The <a href= "image1.html#from_blob">from_blob</a> method constructs an image from a BLOB created by this method.</p> <h4>Arguments</h4> <p>No required arguments, however you can specify the image format (such as JPEG, PNG, etc.) and depth by calling the <a href="imageattrs.html#format">format</a> and <a href= "imageattrs.html#Image.depth">depth</a> attributes, as well as other <a href="info.html">Image::Info</a> attributes as appropriate, in a block associated with the method.</p> <h4>Returns</h4> <p>A string containing the image data represented as a BLOB.</p> <h4>Example</h4> <p><a href="javascript:popup('to_blob.rb.html')"><img src= "ex/to_blob.gif" alt="to_blob example" title= "Click to see the example script" /></a></p> <h4>See also</h4> <p><a href="image1.html#from_blob">from_blob</a></p> <h4>Magick API</h4> <p>ImageToBlob</p> </div> <div class="sig"> <h3 id="to_color">to_color</h3> <p><span class="arg">img</span>.to_color(<span class= "arg">pixel</span>) -> <em>string</em></p> </div> <div class="desc"> <h4>Description</h4> <p>Returns the color name for a pixel. Unlike the <code>Pixel#to_color</code> method, to_color uses the <a href= "imageattrs.html#Image.depth">depth</a> and <a href= "imageattrs.html#Image.matte">matte</a> attributes of the image to determine the color name.</p> <h4>Arguments</h4> <p>A <a href="struct.html#Pixel">Pixel</a> object.</p> <h4>Returns</h4> <p>A <a href="imusage.html#color_names">color name</a>.</p> <h4>Example</h4> <pre> img = Image.read('ex/images/Flower_Hat.jpg').first » ex/images/Flower_Hat.jpg JPEG 200x250 DirectClass 8-bit 9761b pixel = img.pixel_color(img.columns/2, img.rows/2) » #<struct Pixel red=216, green=147, blue=106, opacity=0> img.to_color(pixel) » "#D8936A" </pre> <h4>See also</h4> <p><a href="struct.html#Pixel">Pixel#to_color</a></p> <h4>Magick API</h4> <p>QueryColorname</p> </div> <div class="sig"> <h3 id="transparent">transparent</h3> <p><span class="arg">img</span>.transparent(<span class= "arg">color</span>, <span class= "arg">opacity</span>=TransparentOpacity) -> <em>image</em></p> </div> <div class="desc"> <h4>Description</h4> <p>Changes the opacity value of all the pixels that match <span class="arg">color</span> to the value specified by <span class="arg">opacity</span>. By default the pixel must match exactly, but you can specify a tolerence level by setting the <a href="imageattrs.html#fuzz">fuzz</a> attribute on the image.</p> <h4>Arguments</h4> <dl> <dt>color</dt> <dd>Either a <a href="imusage.html#color_names">color name</a> or a <a href="struct.html#Pixel">pixel</a>.</dd> <dt>opacity</dt> <dd>The new opacity value, either an <a href= "constants.html#Opacity">opacity</a> value or a number between 0 and QuantumRange. The default is TransparentOpacity.</dd> </dl> <h4>Returns</h4> <p>A new image</p> <h4>Example</h4> <p>Mouse over the image to see the original. In this example, all the black pixels are made transparent. The resulting image has been composited over a plasma background, which shows through the transparent pixels.</p> <p class="rollover"><a href= "javascript:popup('transparent.rb.html')"><img src= "ex/transparent_after.gif" title= "Click to see the example script" onmouseover= "this.src='ex/transparent_before.gif'" onmouseout= "this.src='ex/transparent_after.gif'" alt= "transparent example" /></a><img src="ex/images/spin.gif" alt= "" class="spin" title= "Mouse over the example to see the original image" /></p> <h4>See also</h4> <p><a href="image2.html#matte_replace">matte_replace</a>, <a href="draw.html#matte">Draw#matte</a></p> <h4>Magick API</h4> <p>TransparentImage</p> </div> <div class="sig"> <h3 id="transpose">transpose</h3> <p><span class="arg">img</span>.transpose -> <em>image</em></p> </div> <div class="desc"> <h4>Description</h4> <p class="imquote">Creates a horizontal mirror image by reflecting the pixels around the central y-axis while rotating them by 90 degrees.</p> <h4>Returns</h4> <p>A new image</p> <h4>Example</h4> <p class="rollover"><a href= "javascript:popup('transpose.rb.html')"><img src= "ex/transpose.jpg" alt="transpose example" title= "Click to see the example script" onmouseover= "this.src='ex/images/Flower_Hat.jpg'" onmouseout= "this.src='ex/transpose.jpg'" /></a> <img src= "ex/images/spin.gif" alt="" class="spin" style="left:252px;" title="Mouse over the example to see the original image" /></p> <h4>See also</h4> <p><a href="image2.html#flip">flip</a>, <a href= "image2.html#flop">flop</a>, <a href= "image3.html#rotate">rotate</a>, <a href= "#transpose_bang">transpose!</a>, <a href= "image3.html#transverse">transverse</a></p> <h4>Magick API</h4> <p>TransposeImage</p> </div> <div class="sig"> <h3 id="transpose_bang">transpose!</h3> <p><span class="arg">img</span>.transpose! -> <em>self</em></p> </div> <div class="desc"> <h4>Description</h4> <p>In-place form of <a href="#transpose">transpose</a>.</p> <h4>Returns</h4> <p>self</p> </div> <div class="sig"> <h3 id="transverse">transverse</h3> <p><span class="arg">img</span>.transverse -> <em>image</em></p> </div> <div class="desc"> <h4>Description</h4> <p class="imquote">Creates a vertical mirror image by reflecting the pixels around the central x-axis while rotating them by 270 degrees</p> <h4>Returns</h4> <p>A new image</p> <h4>Example</h4> <p class="rollover"><a href= "javascript:popup('transverse.rb.html')"><img src= "ex/transverse.jpg" alt="transverse example" title= "Click to see the example script" onmouseover= "this.src='ex/images/Flower_Hat.jpg'" onmouseout= "this.src='ex/transverse.jpg'" /></a> <img src= "ex/images/spin.gif" alt="" class="spin" style="left:252px;" title="Mouse over the example to see the original image" /></p> <h4>See also</h4> <p><a href="image2.html#flip">flip</a>, <a href= "image2.html#flop">flop</a>, <a href= "image3.html#rotate">rotate</a>, <a href= "image3.html#transpose">transpose</a>, <a href= "#transverse_bang">transverse!</a></p> <h4>Magick API</h4> <p>TransposeImage</p> </div> <div class="sig"> <h3 id="transverse_bang">transverse!</h3> <p><span class="arg">img</span>.transverse! -> <em>self</em></p> </div> <div class="desc"> <h4>Description</h4> <p>In-place form of <a href="#transverse">transverse</a>.</p> <h4>Returns</h4> <p>self</p> </div> <div class="sig"> <h3 id="trim">trim</h3> <p><span class="arg">img</span>.trim(<span class= "arg">reset</span>=false) -> <em>image</em></p> </div> <div class="desc"> <h4>Description</h4> <p class="imquote">Removes the edges that are exactly the same color as the corner pixels. Use the <a href= "imageattrs.html#fuzz">fuzz</a> attribute to make <code>trim</code> remove edges that are nearly the same color as the corner pixels.</p> <h4>Arguments</h4> <p>The trim method retains the offset information in the cropped image. This may cause the image to appear to be surrounded by blank or black space when viewed with an external viewer. This only occurs when the image is saved in a format (such as GIF) that saves offset information. To reset the offset data, use true as the argument to trim. See also <a href="image1.html#crop">crop</a>.</p> <h4>Returns</h4> <p>A new image</p> <h4>Example</h4> <p class="rollover"><a href= "javascript:popup('trim.rb.html')"><img src="ex/trim_after.jpg" onmouseover="this.src='ex/trim_before.jpg'" onmouseout= "this.src='ex/trim_after.jpg'" alt="trim example" title= "Click to see the example script" /></a> <img src= "ex/images/spin.gif" alt="" class="spin" title= "Mouse over the image to see the original image" /></p> <h4>See also</h4> <p><a href="image1.html#crop">crop</a></p> <h4>Magick API</h4> <p>CropImage</p> </div> <div class="sig"> <h3 id="trim_bang">trim!</h3> <p><span class="arg">img</span>.trim!(<span class= "arg">reset</span>=false) -> <em>self</em></p> </div> <div class="desc"> <p>In-place form of <a href="#trim">trim</a>.</p> <h4>Returns</h4> <p>self</p> </div> <div class="sig"> <h3 id="unique_colors">unique_colors</h3> <p><span class="arg">img</span>.unique_colors -> <em>image</em></p> </div> <div class="desc"> <h4>Description</h4> <p>Constructs a new image with one pixel for each unique color in the image. The new image has 1 row. The row has 1 column for each unique pixel in the image.</p> <h4>Returns</h4> <p>A new image</p> <h4>Magick API</h4> <p>UniqueImageColors</p> </div> <div class="sig"> <h3 id="unsharp_mask">unsharp_mask</h3> <p><span class="arg">img</span>.unsharp_mask(<span class= "arg">radius=0.0</span>, <span class="arg">sigma=1.0</span>, <span class="arg">amount=1.0</span>, <span class= "arg">threshold=0.05</span>) -> <em>image</em></p> </div> <div class="desc"> <h4>Description</h4> <p class="imquote">Sharpens an image. We convolve the image with a Gaussian operator of the given <span class= "arg">radius</span> and standard deviation (<span class= "arg">sigma</span>). For reasonable results, <span class= "arg">radius</span> should be larger than <span class= "arg">sigma</span>. Use a radius of 0 and <code>unsharp_mask</code> selects a suitable radius for you.</p> <h4>Arguments</h4> <p>All arguments are optional.</p> <dl> <dt>radius</dt> <dd>The radius of the Gaussian operator. The default is 0.0.</dd> <dt>sigma</dt> <dd>The standard deviation of the Gaussian operator. A good starting value is 1.0, which is the default.</dd> <dt>amount</dt> <dd>The percentage of the blurred image to be added to the receiver, specified as a fraction between 0 and 1.0. A good starting value is 1.0, which is the default.</dd> <dt>threshold</dt> <dd>The threshold needed to apply the amount, specified as a fraction between 0 and 1.0. A good starting value is 0.05, which is the default.</dd> </dl> <h4>Returns</h4> <p>A new image</p> <h4>Example</h4> <p><a href= "javascript:popup:('unsharp_mask.rb.html')"><img src="ex/unsharp_mask.jpg" alt="unsharp_mask example" title= "Click to see the example script" /></a></p> <h4>See also</h4> <p><a href="image2.html#enhance">enhance</a>, <a href= "image2.html#median_filter">median_filter</a>, <a href= "image3.html#reduce_noise">reduce_noise</a>, <a href= "#unsharp_mask_channel">unsharp_mask_channel</a></p> <h4>Magick API</h4> <p>UnsharpMaskImage</p> </div> <div class="sig"> <h3 id="unsharp_mask_channel">unsharp_mask_channel</h3> <p><span class= "arg">img</span>.unsharp_mask_channel(<span class= "arg">radius=0.0</span>, <span class="arg">sigma=1.0</span>, <span class="arg">amount=1.0</span>, <span class= "arg">threshold=0.05</span> [,<span class= "arg">channel</span>...]) -> <em>image</em></p> </div> <div class="desc"> <h4>Description</h4> <p class="imquote">Sharpens an image. We convolve the image with a Gaussian operator of the given <span class= "arg">radius</span> and standard deviation (<span class= "arg">sigma</span>). For reasonable results, <span class= "arg">radius</span> should be larger than <span class= "arg">sigma</span>. Use a radius of 0 and <code>unsharp_mask_channel</code> selects a suitable radius for you.</p> <p>Only the specified channels are sharpened.</p> <h4>Arguments</h4> <p>All arguments are optional.</p> <dl> <dt>radius</dt> <dd>The radius of the Gaussian operator. The default is 0.0.</dd> <dt>sigma</dt> <dd>The standard deviation of the Gaussian operator. A good starting value is 1.0, which is the default.</dd> <dt>amount</dt> <dd>The percentage of the blurred image to be added to the receiver, specified as a fraction between 0 and 1.0. A good starting value is 1.0, which is the default.</dd> <dt>threshold</dt> <dd>The threshold needed to apply the amount, specified as a fraction between 0 and 1.0. A good starting value is 0.05, which is the default.</dd> <dt>channel...</dt> <dd>0 or more <a href= "constants.html#ChannelType">ChannelType</a> arguments. If no channels are specified, all the channels are sharpened. This is the equivalent of <a href= "#unsharp_mask">unsharp_mask</a>.</dd> </dl> <h4>Returns</h4> <p>A new image</p> <h4>See also</h4> <p><a href="image2.html#enhance">enhance</a>, <a href= "image2.html#median_filter">median_filter</a>, <a href= "image3.html#reduce_noise">reduce_noise</a>, <a href= "#unsharp_mask">unsharp_mask</a></p> <h4>Magick API</h4> <p>UnsharpMaskImageChannel</p> </div> <div class="sig"> <h3 id="view">view</h3> <p><span class="arg">img</span>.view(<span class= "arg">x</span>, <span class="arg">y</span>, <span class= "arg">width</span>, <span class="arg">height</span>) -> <em>aView</em><br /> <span class="arg">img</span>.view(<span class="arg">x</span>, <span class="arg">y</span>, <span class="arg">width</span>, <span class="arg">height</span>) { |view| <em>block</em> } -> <em>nil</em></p> </div> <div class="desc"> <h4>Description</h4><code>View</code> is a convenience method that supports getting and setting individual image pixels by <code>[i][j]</code> coordinates. With no associated block, <code>view</code> returns an <a href= "struct.html#view">Image::View</a> object. If the optional code block is given, it will be passed the <code>Image::View</code> object as an argument. The <a href= "struct.html#view_sync">sync</a> method will be called automatically when the block terminates. In this case, <code>view</code> returns <code>nil</code>. <h4>Arguments</h4> <dl> <dt>x, y</dt> <dd>The offset of the view from the top-left corner of the image. Within the view, pixels are relative to the top-left corner of the view, <em>not</em> the image.</dd> <dt>width, height</dt> <dd>The width and height of the view. The view may not extend past the boundaries of <span class="arg">img</span>.</dd> </dl> <h4>Returns</h4> <p>If the optional code block is present, <code>view</code> returns <code>nil</code>. If it is not present, <code>view</code> returns an <code>Image::View</code> object.</p> <h4>See</h4> <p><a href="struct.html#view">Image::View</a></p> <h4>Examples</h4> <p>The example image below has been scaled 500% for clarity.</p> <p><a href="javascript:popup('viewex.rb.html')"><img src= "ex/viewex.gif" title="Click to see the example script" alt= "view example" /></a></p> <pre> img = Image.new(40, 40) {self.background_color = 'lightcyan2'} # The view is 400 pixels square, starting at # column 10, row 5 from the top of the image. img.view( 10, 5, 20, 20) do |view| # Set all the pixels in the view to green. view[][] = Pixel.new(0, QuantumRange) # Change the top and bottom rows to red. view[0][] = 'red' view[-1,1][] = 'red' # Set 6 pixels to black. view[[13,15]][[12,14,16]] = 'black' # Set 1 pixel to yellow. view[5][7] = 'yellow' # Change the green channel of all the # pixels on row 8. view[8][].green = QuantumRange/2 # Change the blue channel of 8 pixels # on column 10. view[4,8][10].blue = QuantumRange end </pre> <h4>See also</h4> <p><a href="image3.html#pixel_color">pixel_color</a>, <a href= "image2.html#get_pixels">get_pixels</a>, <a href= "#store_pixels">store_pixels</a></p> <h4>Notes</h4> <p>The <code>view</code> method introduces a relatively high level of overhead to pixel manipulation compared to methods that use the ImageMagick API to identify and change pixels. I recommend that you use <code>view</code> only when the number of pixels identified in the view is fairly small (a few thousand to a few hundred thousand, depending on your patience and the speed of your computer) and you need this degree of control.</p> </div> <div class="sig"> <h3 id="vignette">vignette</h3> <p><span class="arg">img</span>.vignette(<span class= "arg">x</span>, <span class="arg">y</span>, <span class= "arg">radius</span>=0.0, <span class="arg">sigma</span>=10.0) -> <span class="arg">image</span></p> </div> <div class="desc"> <h4>Description</h4> <p>Gradually shades the edges of the image by transforming the pixels into the background color.</p> <h4>Arguments</h4> <dl> <dt>x</dt> <dd>Influences the amount of background color in the horizontal dimension. Larger values of <span class= "arg">x</span> make the vignette narrower. This argument should be positive and less than image.columns / 2. This argument is optional. If omitted, the default value is 0.10 * <span class="arg">img</span>.columns.</dd> <dt>y</dt> <dd>Influences the amount of background color in the vertical dimension. Larger values of <span class="arg">y</span> make the vignette shorter. This argument should be positive and less than image.rows / 2. This argument is optional. If omitted, the default value is 0.10 * <span class= "arg">img</span>.rows.</dd> <dt>radius, sigma</dt> <dd>Controls the amount of blurring. Larger values of <span class="arg">sigma</span> increase the blurring at the expense of increased execution time. In general, <span class= "arg">radius</span> should be larger than <span class= "arg">sigma</span>, although if <span class= "arg">radius</span> is 0 then ImageMagick will choose a suitable value. <span class="arg">Sigma</span> must be non-zero. Choose a very small value for <span class= "arg">sigma</span> to produce a "hard" edge.</dd> </dl> <h4>Returns</h4> <p>A new image</p> <h4>Example</h4> <p class="rollover"><a href= "javascript:popup('vignette.rb.html')"><img src= "ex/vignette.jpg" alt="vignette example" title= "Click to see the example script" onmouseover= "this.src='ex/images/Flower_Hat.jpg'" onmouseout= "this.src='ex/vignette.jpg'" /></a> <img src= "ex/images/spin.gif" alt="" class="spin" title= "Mouse over the example to see the original image" /></p> <h4>Magick API</h4> <p>VignetteImage</p> <h4>Notes</h4> <p>The image produced by <code>vignette</code> is very similar to the image produced by RMagick's vignette.rb example script. However, the example script gives you more control over the size, shape, and background color of the vignette.</p> </div> <div class="sig"> <h3 id="watermark">watermark</h3> <p><span class="arg">img</span>.watermark(<span class= "arg">mark</span>, <span class="arg">lightness</span>=1.0, <span class="arg">saturation</span>=1.0, <span class= "arg">x_offset</span>=0, <span class="arg">y_offset</span>=0) -> <em>image</em><br /> <span class="arg">img</span>.watermark(<span class= "arg">mark</span>, <span class="arg">lightness</span>=1.0, <span class="arg">saturation</span>=1.0, <span class= "arg">gravity</span>, <span class="arg">x_offset</span>=0, <span class="arg">y_offset</span>=0) -> <em>image</em></p> </div> <div class="desc"> <h4>Description</h4> <p>Composites a watermark image on the target image using the <a href="constants.html#CompositeOperator">Modulate</a> composite operator. This composite operation operates in the HSL colorspace and combines part of the lightness, part of the saturation, and all of the hue of each pixel in the watermark with the corresponding pixel in the target image</p> <h4>Arguments</h4> <dl> <dt>mark</dt> <dd>The watermark image. Either an imagelist or an image. If an imagelist, uses the current image.</dd> <dt>lightness</dt> <dd>The fraction of the lightness component of the watermark pixels to be composited onto the target image. Must be a non-negative number or a string in the form "NN%". If lightness is a number it is interpreted as a percentage. Both 0.25 and "25%" mean 25%. The default is 100%.</dd> <dt>saturation</dt> <dd>The fraction of the saturation component of the watermark pixels to be composited onto the target image. Must be a non-negative number or a string in the form "NN%". If lightness is a number it is interpreted as a percentage. Both 0.25 and "25%" mean 25%. The default is 100%.</dd> <dt>x_offset</dt> <dd>The offset of the watermark, measured from the left-hand side of the target image. The default is 0.</dd> <dt>y_offset</dt> <dd>The offset of the watermark, measured from the top of the target image. The default is 0.</dd> </dl> <p>Watermark can be called with a <span class= "arg">gravity</span> argument or without. When a <span class= "arg">gravity</span> argument is specified but the <span class= "arg">x-</span> and <span class="arg">y-offsets</span> are omitted, the watermark is positioned based on the value of the <span class="arg">gravity</span> argument:</p> <dl> <dt>NorthWestGravity</dt> <dd>The watermark abuts the top and left sides of the image.</dd> <dt>NorthGravity</dt> <dd>The watermark is centered left-to-right and abuts the top of the image.</dd> <dt>NorthEastGravity</dt> <dd>The watermark abuts the top and right sides of the image.</dd> <dt>EastGravity</dt> <dd>The watermark is centered top-to-bottom and abuts the right side of the image.</dd> <dt>SouthEastGravity</dt> <dd>The watermark abuts the bottom and right sides of the image.</dd> <dt>SouthGravity</dt> <dd>The watermark is centered left-to-right and abuts the bottom of the image.</dd> <dt>SouthWestGravity</dt> <dd>The watermark abuts the bottom and left sides of the image.</dd> <dt>WestGravity</dt> <dd>The watermark is centered top-to-bottom and abuts the left side of the image.</dd> <dt>CenterGravity</dt> <dd>The watermark is centered left-to-right and top-to-bottom.</dd> </dl> <p>When the <span class="arg">gravity</span> argument is present and the <span class="arg">x-offset</span> (and optionally the <span class="arg">y-offset</span>) is present, the <span class="arg">x-</span> and <span class= "arg">y-offset</span> are measured from the right and/or bottom edges of the target image based on the value of <span class= "arg">gravity</span>. If the argument is NorthEastGravity, EastGravity, or SouthEastGravity, the <span class= "arg">x-offset</span> is measured from the right side of the image. If the argument is SouthEastGravity, SouthGravity, or SouthWestGravity, the <span class="arg">y-offset</span> is measured from the bottom of the image. All other values are ignored and the <span class="arg">x-</span> and <span class= "arg">y-offset</span> are measured from the upper-left corner of the image.</p> <h4>Returns</h4> <p>A new image</p> <h4>Example</h4> <p>See <a href= "http://www.cit.gu.edu.au/~anthony/graphics/imagick6/annotating/#wmark_image"> "Watermarking with Images"</a> in Anthony Thyssen's <a href= "http://www.cit.gu.edu.au/~anthony/graphics/imagick6/"><cite>Examples of ImageMagick Usage</cite></a>.</p> <p class="rollover"><a href= "javascript:popup('watermark.rb.html')"><img src= "ex/watermark.jpg" alt="watermark example" title= "Click to see the example script" onmouseover= "this.src='ex/images/Flower_Hat.jpg'" onmouseout= "this.src='ex/watermark.jpg'" /></a> <img src= "ex/images/spin.gif" alt="" class="spin" title= "Mouse over the example to see the original image" /></p> <h4>See also</h4> <p><a href="image1.html#composite">composite</a>, <a href= "#stegano">stegano</a></p> </div> <div class="sig"> <h3 id="wave">wave</h3> <p><span class="arg">img</span>.wave(<span class= "arg">amplitude</span>=25.0, <span class= "arg">wavelength</span>=150.0) -> <em>image</em></p> </div> <div class="desc"> <h4>Description</h4> <p class="imquote">Creates a "ripple" effect in the image by shifting the pixels vertically along a sine wave whose <span class="arg">amplitude</span> and <span class= "arg">wavelength</span> is specified by the given parameters.</p> <h4>Returns</h4> <p>A new image</p> <h4>Example</h4> <p class="rollover"><a href="javascript:popup('wave.rb.html')"> <!-- This img tag displays the original image when the mouse is over --> <img style= "padding-top:25px; padding-bottom:25px; display:none" id= "nowave" title="Click to see the example script" onmouseout= "this.style.display='none'; waved.style.display='';" src= "ex/images/Flower_Hat.jpg" alt="wave example" /> <!-- This img tag displays the framed image when the mouse is not over --><img class="hide" id="waved" onmouseover= "this.style.display='none'; nowave.style.display='';" src= "ex/wave.jpg" alt="wave example" /></a> <img src= "ex/images/spin.gif" alt="" class="spin" title= "Mouse over the example to see the original image" /></p> <h4>Magick API</h4> <p>WaveImage</p> <h4>See also</h4> <p><a href= "imageattrs.html#virtual_pixel_method">virtual_pixel_method</a></p> </div> <div class="sig"> <h3 id="wet_floor">wet_floor</h3> <p><span class="arg">img</span>.wet_floor(<span class= "arg">intial=0.5</span>, <span class="arg">rate=1.0</span>) -> <em>image</em></p> </div> <div class="desc"> <h4>Description</h4> <p>Creates a <a href= "http://en.wikipedia.org/wiki/Wet_floor_effect">"wet floor"</a> reflection. The reflection is an inverted copy of the image that changes from partially transparent to entirely transparent. By default only the bottom third of the image appears in the reflection.</p> <p>Note that the output image is just the reflection. This makes it easy to apply further transformations to the reflection before combining it with the original image.</p> <h4>Arguments</h4> <dl> <dt>initial</dt> <dd>A value between 0.0 and 1.0 that specifies the initial percentage of transparency. Higher values cause the top of the reflection to be more transparent, lower values less transparent. The default is 0.5, which means that the top of the reflection is 50% transparent.</dd> <dt>rate</dt> <dd>A non-negative value that specifies how rapidly the reflection transitions from the initial level of transparency to entirely transparent. The default value is 1.0, which means that the transition occurs in 1/3 the image height. Values greater than 1.0 speed up the transition (the reflection will have fewer rows), values lower than 1.0 slow down the transition (the reflection will have more rows). A value of 0.0 means that the level of transparency will not change.</dd> </dl> <h4>Returns</h4> <p>A new image</p> <h4>Example</h4> <p>Here are four examples of <code>wet_floor</code>. The top image shows the result of appending the default reflection to the original image. The second image shows the result of decreasing the initial transparency to 0.25 and using 0.5 as the <span class="arg">rate</span> argument. The third image uses the same reflection as the second image but has a slant added. The bottom image is the same as the third image but with a ripple effect.</p> <p><a href="javascript:popup('wet_floor.rb.html')"><img src= "ex/wet_floor.gif" title="Click to see the example script" alt= "wet floor example" /></a></p> </div> <div class="sig"> <h3 id="white_threshold">white_threshold</h3> <p><span class="arg">img</span>.white_threshold(<span class= "arg">red_channel</span> [, <span class= "arg">green_channel</span>[, <span class= "arg">blue_channel</span>[, <span class= "arg">opacity_channel</span>]]]) -> <em>image</em></p> </div> <div class="desc"> <h4>Description</h4> <p class="imquote">Forces all pixels above the threshold into white while leaving all pixels below the threshold unchanged.</p> <h4>Arguments</h4> <p>Each channel argument is a number between 0 and QuantumRange. All arguments except the first may be omitted. If the <span class="arg">green_channel</span> or <span class= "arg">blue_channel</span> argument is omitted, the default value is the <span class="arg">red_channel</span> value. If the <span class="arg">opacity_channel</span> argument is omitted, the default value is <a href= "constants.html#Opacity">OpaqueOpacity</a>.</p> <h4>Returns</h4> <p>A new image</p> <h4>See also</h4> <p><a href="image1.html#black_threshold">black_threshold</a>, <a href="image1.html#bilevel_channel">bilevel_channel</a></p> <h4>Magick API</h4> <p>WhiteThresholdImage</p> </div> <div class="sig"> <h3 id="write">write</h3> <p><span class="arg">img</span>.write(<span class= "arg">filename</span>) <span class="arg">[ { optional arguments } ]</span> -> <em>self</em><br /> <span class="arg">img</span>.write(<span class= "arg">file</span>) <span class="arg">[ { optional arguments } ]</span> -> <em>self</em></p> </div> <div class="desc"> <h4>Description</h4> <p>Writes the image to the specified file. ImageMagick determines image format from the <a href= "imusage.html#formats">prefix or extension</a>.</p> <p>If the argument is an open file, ImageMagick will write the image in its current format. You can force a different format by setting the image's <a href= "imageattrs.html#Image.format">format</a> attribute.</p> <h4>Arguments</h4> <p>A file name or open file object. You may also specify optional arguments by setting <a href= "info.html">Image::Info</a> attributes in an associated block.</p> <h4>Returns</h4> <p><code>self</code>, or <code>nil</code> if the image format cannot be determined.</p> <h4>Example</h4> <p>Almost all of the examples call <code>write</code>.</p> <h4>See also</h4> <p><a href="ilist.html#write">ImageList#write</a></p> <h4>Magick API</h4> <p>WriteImage</p> </div> <p class="spacer"> </p> <div class="nav"> « <a href="image2.html">Prev</a> | <a href= "index.html">Contents</a> | <a href= "draw.html">Next</a> » </div> </body> </html>