<!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 1st December 2004), see www.w3.org" /> <title>RMagick 1.15.15: class Image (instance methods, part 2)</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" src="scripts/stripeTables.js"> </script> <script type="text/javascript"> //<![CDATA[ addLoadEvent(stripeTables); //]]> </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[*/ #iptc { border: thin solid black; } #iptc th { background-color: #c0c0c0; } td.ds { text-align: right; } /*]]>*/ </style> </head> <body> <h6 id="header">RMagick 1.15.15 User's Guide and Reference</h6> <div class="nav"> « <a href="image1.html">Prev</a> | <a href= "index.html">Contents</a> | <a href= "image3.html">Next</a> » </div> <h1>class Image <span class="superclass">< Object</span> (class and instance methods, part 2)<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="#enhance">enhance</a></li> <li><a href="#equalize">equalize</a></li> <li><a href="#erase_bang">erase!</a></li> <li><a href="#export_pixels">export_pixels</a></li> <li><a href= "#export_pixels_to_str">export_pixels_to_str</a></li> <li><a href= "#find_similar_region">find_similar_region</a></li> <li><a href="#flip">flip</a></li> <li><a href="#flip_bang">flip!</a></li> <li><a href="#flop">flop</a></li> <li><a href="#flop_bang">flop!</a></li> <li><a href="#frame">frame</a></li> <li><a href="#freeze">freeze</a></li> <li><a href="#gamma_channel">gamma_channel</a></li> <li><a href="#gamma_correct">gamma_correct</a></li> <li><a href="#gaussian_blur">gaussian_blur</a></li> <li><a href= "#gaussian_blur_channel">gaussian_blur_channel</a></li> <li><a href= "#get_exif_by_entry">get_exif_by_entry</a></li> <li><a href= "#get_exif_by_number">get_exif_by_number</a></li> </ul> </div> <div class="toccol"> <ul> <li><a href="#get_iptc_dataset">get_iptc_dataset</a></li> <li><a href="#get_pixels">get_pixels</a></li> <li><a href="#gray_q">gray?</a></li> <li><a href= "#grayscale_pseudo_class">grayscale_pseudo_class</a></li> <li><a href="#grey_q">grey?</a></li> <li><a href="#implode">implode</a></li> <li><a href="#import_pixels">import_pixels</a></li> <li><a href="#inspect">inspect</a></li> <li><a href="#level">level</a></li> <li><a href="#level_channel">level_channel</a></li> <li><a href="#linear_stretch">linear_stretch</a></li> <li><a href="#magnify">magnify</a></li> <li><a href="#magnify_bang">magnify!</a></li> <li><a href="#map">map</a></li> <li><a href= "#matte_fill_to_border">matte_fill_to_border</a></li> <li><a href="#matte_floodfill">matte_floodfill</a></li> <li><a href="#matte_point">matte_point</a></li> <li><a href="#matte_replace">matte_replace</a></li> </ul> </div> <div class="toccol"> <ul> <li><a href="#matte_reset_bang">matte_reset!</a></li> <li><a href="#median_filter">median_filter</a></li> <li><a href="#minify">minify</a></li> <li><a href="#minify_bang">minify!</a></li> <li><a href="#modulate">modulate</a></li> <li><a href="#monochrome_q">monochrome?</a></li> <li><a href="#motion_blur">motion_blur</a></li> <li><a href="#negate">negate</a></li> <li><a href="#negate_channel">negate_channel</a></li> <li><a href="#normalize">normalize</a></li> <li><a href= "#normalize_channel">normalize_channel</a></li> <li><a href="#oil_paint">oil_paint</a></li> <li><a href="#opaque">opaque</a></li> <li><a href="#opaque_q">opaque?</a></li> <li><a href="#ordered_dither">ordered_dither</a></li> <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> </ul> </div> </div> </div> <h2 class="methods">instance methods</h2> <div class="sig"> <h3 id="enhance">enhance</h3> <p><span class="arg">image</span>.enhance -> <em>anImage</em></p> </div> <div class="desc"> <h4>Description</h4> <p class="imquote">Applies a digital filter that improves the quality of a noisy image.</p> <h4>Returns</h4> <p>A new image</p> <h4>Example</h4> <p>The left-hand side has had noise added by <code><a href= "#add_noise">add_noise</a></code>. The right-hand side is the result after using <code>enhance</code>.</p> <p><a href="javascript:popup('enhance.rb.html')"><img src= "ex/enhance.jpg" alt="enhance example" title= "Click to see the example script" /></a></p> <h4>See also</h4> <p><a href="#median_filter">median_filter</a>, <a href="image3.html#reduce_noise">reduce_noise</a>, <a href= "image3.html#unsharp_mask">unsharp_mask</a></p> <h4>Magick API</h4> <p>EnhanceImage</p> </div> <div class="sig"> <h3 id="equalize">equalize</h3> <p><span class="arg">image</span>.equalize -> <em>anImage</em></p> </div> <div class="desc"> <h4>Description</h4> <p class="imquote">Applies a histogram equalization to the image.</p> <h4>Returns</h4> <p>A new image</p> <h4>Example</h4> <p class="rollover"><a href= "javascript:popup('equalize.rb.html')"><img onmouseover= "this.src='ex/images/Flower_Hat.jpg'" onmouseout= "this.src='ex/equalize.jpg'" src="ex/equalize.jpg" alt= "equalize 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>EqualizeImage</p> </div> <div class="sig"> <h3 id="erase_bang">erase!</h3> <p><span class="arg">image</span>.erase! -> <em>image</em></p> </div> <div class="desc"> <h4>Description</h4> <p>Sets the entire image to the <a href= "imageattrs.html#background_color">background color</a>.</p> <h4>Returns</h4>self <h4>See also</h4> <p><a href="image1.html#color_reset_bang">color_reset!</a></p> <h4>Magick API</h4> <p>SetImage</p> </div> <div class="sig"> <h3 id="export_pixels">export_pixels</h3> <p><span class="arg">image</span>.export_pixels(<span class= "arg">x</span>=0, <span class="arg">y</span>=0, <span class= "arg">columns</span>=<span class="arg">image</span>.columns, <span class="arg">rows</span>=<span class= "arg">image</span>.rows, <span class="arg">map</span>="RGB") -> <em>anArray</em></p> </div> <div class="desc"> <h4>Description</h4> <p>Extracts the pixel data from the specified rectangle and returns it as an array of <code>Integer</code> values.</p> <p>The array returned by <code>export_pixels</code> is suitable for use as an argument to <code>import_pixels</code>.</p> <h4>Arguments</h4> <dl> <dt>x, y</dt> <dd>The offset of the rectangle from the upper-left corner of the image.</dd> <dt>columns, rows</dt> <dd>The width and height of the rectangle.</dd> <dt>map</dt> <dd>A string that describes which pixel channel data is desired and the order in which it should be stored. <span class="imquote">It can be any combination or order of R = red, G = green, B = blue, A = alpha, C = cyan, Y = yellow, M = magenta, K = black, I = intensity (for grayscale), or P = pad.</span></dd> </dl> <h4>Returns</h4>An array <h4>Example</h4> <pre> # Export the r'th scanline from an image in red-green-blue order scanline = img.export_pixels(0, r, img.columns, 1, "RGB"); </pre> <h4>See also</h4> <p><a href="image1.html#dispatch">dispatch</a>, <a href= "#export_pixels_to_str">export_pixels_to_str</a>, <a href= "#import_pixels">import_pixels</a>, <a href= "#get_pixels">get_pixels</a></p> <h4>Magick API</h4> <p>ExportImagePixels</p> <h4>Note</h4> <p>This method replaces the <code>dispatch</code> method.</p> </div> <div class="sig"> <h3 id="export_pixels_to_str">export_pixels_to_str</h3> <p><span class= "arg">image</span>.export_pixels_to_str(<span class= "arg">x</span>=0, <span class="arg">y</span>=0, <span class= "arg">columns</span>=<span class="arg">image</span>.columns, <span class="arg">rows</span>=<span class= "arg">image</span>.rows, <span class="arg">map</span>="RGB", <span class="arg">type</span>=<code>Magick::CharPixel</code>) -> <em>aString</em></p> </div> <div class="desc"> <h4>Description</h4> <p>Extracts the pixel data from the specified rectangle and returns it as a string. If you need to get the pixel data in a memory buffer (as input to another application, for example), this method is much, much faster than <a href= "#export_pixels">export_pixels</a> or <a href= "#get_pixels">get_pixels</a>.</p> <p>The string returned by <code>export_pixels_to_str</code> is suitable for use as an argument to <code>import_pixels</code>.</p> <p><strong>Note:</strong> You can also use <a href= "image3.html#to_blob">to_blob</a> to convert an image into a string.</p> <h4>Arguments</h4> <dl> <dt>x, y</dt> <dd>The offset of the rectangle from the upper-left corner of the image.</dd> <dt>columns, rows</dt> <dd>The width and height of the rectangle.</dd> <dt>map</dt> <dd>A string that describes which pixel channel data is desired and the order in which it should be stored. <span class="imquote">It can be any combination or order of R = red, G = green, B = blue, A = alpha, C = cyan, Y = yellow, M = magenta, K = black, I = intensity (for grayscale), or P = pad.</span></dd> <dt>type</dt> <dd>A <a href="constants.html#StorageType">StorageType</a> value that specifies the C datatype to which the pixel data will be converted. The default is <code>CharPixel</code>, which means that the pixel values will be stored as C <code>unsigned char</code>s.</dd> </dl> <h4>Returns</h4>A string <h4>See also</h4> <p><a href="image1.html#dispatch">dispatch</a>, <a href= "#export_pixels">export_pixels</a>, <a href= "#import_pixels">import_pixels</a>, <a href= "#get_pixels">get_pixels</a></p> <h4>Magick API</h4> <p>ExportImagePixels</p> </div> <div class="sig"> <h3 id="find_similar_region">find_similar_region</h3> <p><span class= "arg">image</span>.find_similar_region(<span class= "arg">target</span>, <span class="arg">x</span>=0, <span class= "arg">y</span>=0) -> <em>[rx, ry]</em></p> </div> <div class="desc"> <h4>Description</h4> <p>This interesting method searches for a rectangle in the image that is <em>similar</em> to the target. For the rectangle to be <em>similar</em> each pixel in the rectangle must match the corresponding pixel in the target image within the range specified by the <code>fuzz</code> attributes of the image and the target image.</p> <h4>Arguments</h4> <dl> <dt>target</dt> <dd>An image that forms the target of the search. This image can be any size.</dd> <dt>x, y</dt> <dd>The starting <em>x-</em> and <em>y-</em>offsets for the search. If omitted both <span class="arg">x</span> and <span class="arg">y</span> default to 0.</dd> </dl> <h4>Returns</h4> <p>If the search succeeds, the return value is an array with 2 elements. These elements are the <em>x-</em> and <em>y-</em>offsets of the matching rectangle. If the search fails the return value is <code>nil</code>.</p> <h4>Magick API</h4> <p>IsImageSimilar (available in ImageMagick 6.2.8)</p> </div> <div class="sig"> <h3 id="flip">flip</h3> <p><span class="arg">image</span>.flip -> <em>anImage</em></p> </div> <div class="desc"> <h4>Description</h4> <p>Create a vertical mirror image of the receiver.</p> <h4>Returns</h4> <p>A new image</p> <h4>Example</h4> <p class="rollover"><a href= "javascript:popup('flip.rb.html')"><img onmouseover= "this.src='ex/images/Flower_Hat.jpg'" onmouseout= "this.src='ex/flip.jpg'" src="ex/flip.jpg" alt="flip 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#affine_transform">affine_transform</a>, <a href="#flip_bang">flip!</a>, <a href="#flop">flop</a>, <a href="image3.html#rotate">rotate</a>, <a href= "image3.html#transpose">transpose</a>, <a href= "image3.html#transverse">transverse</a></p> <h4>Magick API</h4> <p>FlipImage</p> </div> <div class="sig"> <h3 id="flip_bang">flip!</h3> <p><span class="arg">image</span>.flip! -> <em>image</em></p> </div> <div class="desc"> <h4>Description</h4> <p>In-place form of <a href="#flip">flip</a>.</p> <h4>Returns</h4> <p>self</p> </div> <div class="sig"> <h3 id="flop">flop</h3> <p><span class="arg">image</span>.flop -> <em>anImage</em></p> </div> <div class="desc"> <h4>Description</h4> <p>Create a horizontal mirror image of the receiver.</p> <h4>Returns</h4> <p>A new image</p> <h4>Example</h4> <p class="rollover"><a href= "javascript:popup('flop.rb.html')"><img onmouseover= "this.src='ex/images/Flower_Hat.jpg'" onmouseout= "this.src='ex/flop.jpg'" src="ex/flop.jpg" alt="flop 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#affine_transform">affine_transform</a>, <a href="#flip">flip</a>, <a href="#flop_bang">flop!</a>, <a href="image3.html#rotate">rotate</a>, <a href= "image3.html#transpose">transpose</a>, <a href= "image3.html#transverse">transverse</a></p> <h4>Magick API</h4> <p>FlopImage</p> </div> <div class="sig"> <h3 id="flop_bang">flop!</h3> <p><span class="arg">image</span>.flop! -> <em>image</em></p> </div> <div class="desc"> <h4>Description</h4> <p>In-place form of <a href="#flop">flop</a>.</p> <h4>Returns</h4> <p>self</p> </div> <div class="sig"> <h3 id="frame">frame</h3> <p><span class="arg">image</span>.frame(<span class= "arg">width</span>=25, <span class="arg">height</span>=25, <span class="arg">x</span>=25, <span class="arg">y</span>=25, <span class="arg">inner_bevel</span>=6, <span class= "arg">outer_bevel</span>=6, <span class= "arg">color</span>=<code><a href= "imageattrs.html#matte_color">matte_color</a></code>) -> <em>anImage</em></p> </div> <div class="desc"> <h4>Description</h4> <p>Adds a simulated 3D border.</p> <h4>Arguments</h4> <dl> <dt>width</dt> <dd>The width of the left and right sides.</dd> <dt>height</dt> <dd>The height of the top and bottom sides.</dd> <dt>x, y</dt> <dd>The image does not have to be centered in the border. These two arguments specify the offset of the image from the upper-left outside corner of the border.</dd> <dt>inner_bevel, outer_bevel</dt> <dd>The width of the inner and outer shadows of the border. These values should be much smaller than the width and height and cannot be greater than 1/2 the lesser of the width or height.</dd> <dt>color</dt> <dd>The border color. By default the color is the <a href= "imageattrs.html#matte_color">matte color</a>.</dd> </dl> <h4>Returns</h4> <p>A new image</p> <h4>Example</h4> <p class="rollover"><a href= "javascript:popup('frame.rb.html')"> <!-- This img tag displays the original image when the mouse is over --> <img style="padding:25px; display:none" id="frameless" onmouseout="this.style.display='none';framed.style.display='';" src="ex/images/Flower_Hat.jpg" alt="frame example" title= "Click to see the example script" /><!-- This img tag displays the framed image when the mouse is not over --><img onmouseover="this.style.display='none';frameless.style.display='';" src="ex/frame.jpg" alt="frame 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#border">border</a></p> <h4>Magick API</h4> <p>FrameImage</p> </div> <div class="sig"> <h3 id="freeze">freeze</h3> <p><span class="arg">image</span>.freeze -> <em>self</em></p> </div> <div class="desc"> <h4>Description</h4> <p>Prevent further modifications to the image.</p> <h4>Returns</h4> <p>self</p> </div> <div class="sig"> <h3 id="gamma_channel">gamma_channel</h3> <p><span class="arg">image</span>.gamma_channel(<span class= "arg">gamma</span>, [<span class="arg">channel</span>...]) = <em>anImage</em></p> </div> <div class="desc"> <h4>Description</h4> <p class="imquote">Gamma-correct a particular image channel. The same image viewed on different devices will have perceptual differences in the way the image's intensities are represented on the screen.</p> <h4>Arguments</h4> <dl> <dt>gamma</dt> <dd class="imquote">Values typically range from 0.8 to 2.3. You can also reduce the influence of a particular channel with a gamma value of 0.</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 corrected using the <span class="arg">gamma</span> value.</dd> </dl> <h4>Returns</h4> <p>A new image</p> <h4>See also</h4> <p>The older <a href="#gamma_correct">gamma_correct</a> method is implemented in terms of <code>gamma_channel</code>.</p> <h4>Magick API</h4> <p>GammaImageChannel</p> </div> <div class="sig"> <h3 id="gamma_correct">gamma_correct</h3> <p><span class="arg">image</span>.gamma_correct(<span class= "arg">red_gamma</span>[,<span class="arg">green_gamma</span>[, <span class="arg">blue_gamma</span>]]) -> <em>anImage</em></p> </div> <div class="desc"> <h4>Description</h4> <p>Gamma-correct an image. The same image viewed on different devices will have perceptual differences in the way the image's intensities are represented on the screen.</p> <h4>Arguments</h4> <p>You must specify at least <code>red_gamma</code>. Omitted arguments take on the value of the last specified argument. <span class="imquote">Values typically range from 0.8 to 2.3.</span></p> <h4>Returns</h4> <p>A new image</p> <h4>See also</h4> <p><a href="#gamma_channel">gamma_channel</a></p> <h4>Magick API</h4> <p>GammaImage</p> </div> <div class="sig"> <h3 id="gaussian_blur">gaussian_blur</h3> <p><span class="arg">image</span>.gaussian_blur(<span class= "arg">radius</span>=0.0, <span class="arg">sigma</span>=1.0) -> <em>anImage</em></p> </div> <div class="desc"> <h4>Description</h4> <p class="imquote">Blurs an image. We convolve the image with a Gaussian operator of the given radius and standard deviation (sigma).</p> <h4>Arguments</h4> <dl> <dt>radius</dt> <dd>A <code>Float</code> value representing <span class= "imquote">the radius of the Gaussian, in pixels, not counting the center pixel.</span></dd> <dt>sigma</dt> <dd>A <code>Float</code> value representing the standard deviation of the Gaussian operator, in pixels. This argument must be > 0.0.</dd> </dl> <h4>Returns</h4> <p>A new image</p> <h4>Example</h4> <p><code>gaussian_blur(0.0, 3.0)</code></p> <p class="rollover"><a href= "javascript:popup('gaussian_blur.rb.html')"><img onmouseover= "this.src='ex/images/Flower_Hat.jpg'" onmouseout= "this.src='ex/gaussian_blur.jpg'" src="ex/gaussian_blur.jpg" alt="gaussian_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= "#motion_blur">motion_blur</a>, <a href= "image3.html#radial_blur">radial_blur</a></p> <h4>Magick API</h4> <p>GaussianBlurImage</p> </div> <div class="sig"> <h3 id="gaussian_blur_channel">gaussian_blur_channel</h3> <p><span class= "arg">image</span>.gaussian_blur_channel(<span class= "arg">radius</span>=0.0, <span class="arg">sigma</span>=1.0[, <span class="arg">channel</span>...]) -> <em>anImage</em></p> </div> <div class="desc"> <h4>Description</h4> <p>Blurs the selected channel or channels using a Gaussian operator of the specified radius and standard deviation.</p> <h4>Arguments</h4> <dl> <dt>radius</dt> <dd>A <code>Float</code> value representing <span class= "imquote">the radius of the Gaussian, in pixels, not counting the center pixel.</span></dd> <dt>sigma</dt> <dd>A <code>Float</code> value representing the standard deviation of the Gaussian operator, in pixels. This argument must be > 0.0.</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. This is the same as using <a href= "#gaussian_blur">gaussian_blur</a>.</dd> </dl> <h4>Returns</h4> <p>A new image</p> <h4>See also</h4> <p><a href="image1.html#blur_channel">blur_channel</a></p> <h4>Magick API</h4>GaussianBlurImageChannel (available in ImageMagick 6.0.0) </div> <div class="sig"> <h3 id="get_exif_by_entry">get_exif_by_entry</h3> <p><span class= "arg">image</span>.get_exif_by_entry(<span class="arg">[name]*</span>) -> <em>anArray</em></p> </div> <div class="desc"> <h4>Description</h4> <p>Returns the value associated with the specified EXIF entry name or names. If no names are specified, returns all the entries. The return value is an array containing one or more [name, value] elements.</p> <h4>Arguments</h4> <p>Zero or more EXIF entry names.</p> <h4>Returns</h4> <p>The elements in the returned array are 2-element arrays in the form [name, value]. If ×Magick does not know the name for an entry it uses "unknown." There may be more than one entry for "unknown" in the returned array. If there is no entry with the specified name the value is set to <code>nil</code>.</p> <h4>Example</h4> <pre> image.get_exif_by_entry('Make') » [["Make", "Canon"]] image.get_exif_by_entry("ShutterSpeedValue") » [["ShutterSpeedValue", "189/32"]] image.get_exif_by_entry() » [["Make", "Canon"], ["ShutterSpeedValue", "189/32"] ...] </pre> <h4>See also</h4> <p><a href="#get_exif_by_number">get_exif_by_number</a></p> </div> <div class="sig"> <h3 id="get_exif_by_number">get_exif_by_number</h3> <p><span class= "arg">image</span>.get_exif_by_number(<span class= "arg">[tag]*</span>) -> <em>aHash</em></p> </div> <div class="desc"> <h4>Description</h4> <p>Returns the value associated with the specified EXIF tag number or numbers. If no numbers are specified, returns all the tags. The return value is a hash. The hash keys are EXIF tag numbers. The values are the values associated with the tags.</p> <h4>Arguments</h4> <p>Zero or more EXIF tag numbers.</p> <h4>Returns</h4> <p>A hash. If there is no tag with the specified number the value is set to <code>nil</code>.</p> <h4>Example</h4> <pre> image.get_exif_by_number(271) » {271=>"Canon"} image.get_exif_by_number(37377) » {37377=>"189/32"} image.get_exif_by_number() » {271=>"Canon", 37377=>"189/32" ...} </pre> <h4>See also</h4> <p><a href="#get_exif_by_entry">get_exif_by_entry</a></p> </div> <div class="sig"> <h3 id="get_iptc_dataset">get_iptc_dataset</h3> <p><span class="arg">image</span>.get_iptc_dataset(<span class= "arg">ds</span>) -> <em>aString</em></p> </div> <div class="desc"> <h4>Description</h4> <p>Retrieves the data field for the specified DataSet, or <code>nil</code> if the DataSet is not used or the data field has length 0.</p> <h4>Arguments</h4> <p>RMagick defines the following constants for use as arguments to this method. All the constants are in the Magick::IPTC namespace. Notice that some DataSets have two names.</p> <table id="iptc" class="striped" summary= "IPTC dataset constants"> <tr> <th>Constant</th> <th>Record:DataSet</th> </tr> <tr> <td>Envelope::Model_Version</td> <td class="ds">1:00</td> </tr> <tr> <td>Envelope::Destination</td> <td class="ds">1:05</td> </tr> <tr> <td>Envelope::UNO</td> <td class="ds">1:100</td> </tr> <tr> <td>Envelope::Unique_Name_of_Object</td> <td class="ds">1:100</td> </tr> <tr> <td>Envelope::ARM_Identifier</td> <td class="ds">1:120</td> </tr> <tr> <td>Envelope::ARM_Version</td> <td class="ds">1:122</td> </tr> <tr> <td>Envelope::File_Format</td> <td class="ds">1:20</td> </tr> <tr> <td>Envelope::File_Format_Version</td> <td class="ds">1:22</td> </tr> <tr> <td>Envelope::Service_Identifier</td> <td class="ds">1:30</td> </tr> <tr> <td>Envelope::Envelope_Number</td> <td class="ds">1:40</td> </tr> <tr> <td>Envelope::Product_ID</td> <td class="ds">1:50</td> </tr> <tr> <td>Envelope::Envelope_Priority</td> <td class="ds">1:60</td> </tr> <tr> <td>Envelope::Date_Sent</td> <td class="ds">1:70</td> </tr> <tr> <td>Envelope::Time_Sent</td> <td class="ds">1:80</td> </tr> <tr> <td>Envelope::Coded_Character_Set</td> <td class="ds">1:90</td> </tr> <tr> <td>Application::Object_Type_Reference</td> <td class="ds">2:03</td> </tr> <tr> <td>Application::Object_Name</td> <td class="ds">2:05</td> </tr> <tr> <td>Application::Title</td> <td class="ds">2:05</td> </tr> <tr> <td>Application::Edit_Status</td> <td class="ds">2:07</td> </tr> <tr> <td>Application::Editorial_Update</td> <td class="ds">2:08</td> </tr> <tr> <td>Application::Urgency</td> <td class="ds">2:10</td> </tr> <tr> <td>Application::Country_Primary_Location_Code</td> <td class="ds">2:100</td> </tr> <tr> <td>Application::Country_Primary_Location_Name</td> <td class="ds">2:101</td> </tr> <tr> <td>Application::Original_Transmission_Reference</td> <td class="ds">2:103</td> </tr> <tr> <td>Application::Headline</td> <td class="ds">2:105</td> </tr> <tr> <td>Application::Credit</td> <td class="ds">2:110</td> </tr> <tr> <td>Application::Source</td> <td class="ds">2:115</td> </tr> <tr> <td>Application::Copyright_Notice</td> <td class="ds">2:116</td> </tr> <tr> <td>Application::Contact</td> <td class="ds">2:118</td> </tr> <tr> <td>Application::Subject_Reference</td> <td class="ds">2:12</td> </tr> <tr> <td>Application::Abstract</td> <td class="ds">2:120</td> </tr> <tr> <td>Application::Caption</td> <td class="ds">2:120</td> </tr> <tr> <td>Application::Caption_Writer</td> <td class="ds">2:122</td> </tr> <tr> <td>Application::Editor</td> <td class="ds">2:122</td> </tr> <tr> <td>Application::Rasterized_Caption</td> <td class="ds">2:125</td> </tr> <tr> <td>Application::Image_Type</td> <td class="ds">2:130</td> </tr> <tr> <td>Application::Image_Orientation</td> <td class="ds">2:131</td> </tr> <tr> <td>Application::Language_Identifier</td> <td class="ds">2:135</td> </tr> <tr> <td>Application::Category</td> <td class="ds">2:15</td> </tr> <tr> <td>Application::Audio_Type</td> <td class="ds">2:150</td> </tr> <tr> <td>Application::Audio_Sampling_Rate</td> <td class="ds">2:151</td> </tr> <tr> <td>Application::Audio_Sampling_Resolution</td> <td class="ds">2:152</td> </tr> <tr> <td>Application::Audio_Duration</td> <td class="ds">2:153</td> </tr> <tr> <td>Application::Audio_Outcue</td> <td class="ds">2:154</td> </tr> <tr> <td>Application::Supplemental_Category</td> <td class="ds">2:20</td> </tr> <tr> <td>Application::ObjectData_Preview_File_Format</td> <td class="ds">2:200</td> </tr> <tr> <td> Application::ObjectData_Preview_File_Format_Version</td> <td class="ds">2:201</td> </tr> <tr> <td>Application::ObjectData_Preview_Data</td> <td class="ds">2:202</td> </tr> <tr> <td>Application::Fixture_Identifier</td> <td class="ds">2:22</td> </tr> <tr> <td>Application::Keywords</td> <td class="ds">2:25</td> </tr> <tr> <td>Application::Content_Location_Code</td> <td class="ds">2:26</td> </tr> <tr> <td>Application::Content_Location_Name</td> <td class="ds">2:27</td> </tr> <tr> <td>Application::Release_Date</td> <td class="ds">2:30</td> </tr> <tr> <td>Application::Release_Time</td> <td class="ds">2:35</td> </tr> <tr> <td>Application::Expiration_Time</td> <td class="ds">2:35</td> </tr> <tr> <td>Application::Expiration_Date</td> <td class="ds">2:37</td> </tr> <tr> <td>Application::Special_Instructions</td> <td class="ds">2:40</td> </tr> <tr> <td>Application::Action_Advised</td> <td class="ds">2:42</td> </tr> <tr> <td>Application::Reference_Service</td> <td class="ds">2:45</td> </tr> <tr> <td>Application::Reference_Date</td> <td class="ds">2:47</td> </tr> <tr> <td>Application::Reference_Number</td> <td class="ds">2:50</td> </tr> <tr> <td>Application::Date_Created</td> <td class="ds">2:55</td> </tr> <tr> <td>Application::Time_Created</td> <td class="ds">2:60</td> </tr> <tr> <td>Application::Digital_Creation_Date</td> <td class="ds">2:62</td> </tr> <tr> <td>Application::Digital_Creation_Time</td> <td class="ds">2:63</td> </tr> <tr> <td>Application::Originating_Program</td> <td class="ds">2:65</td> </tr> <tr> <td>Application::Program_Version</td> <td class="ds">2:70</td> </tr> <tr> <td>Application::Object_Cycle</td> <td class="ds">2:75</td> </tr> <tr> <td>Application::Author</td> <td class="ds">2:80</td> </tr> <tr> <td>Application::By_Line</td> <td class="ds">2:80</td> </tr> <tr> <td>Application::Author_Position</td> <td class="ds">2:85</td> </tr> <tr> <td>Application::By_Line_Title</td> <td class="ds">2:85</td> </tr> <tr> <td>Application::City</td> <td class="ds">2:90</td> </tr> <tr> <td>Application::Sub_Location</td> <td class="ds">2:92</td> </tr> <tr> <td>Application::Province</td> <td class="ds">2:95</td> </tr> <tr> <td>Application::State</td> <td class="ds">2:95</td> </tr> <tr> <td>Pre_ObjectData_Descriptor::Size_Mode</td> <td class="ds">7:10</td> </tr> <tr> <td>Pre_ObjectData_Descriptor::Max_Subfile_Size</td> <td class="ds">7:20</td> </tr> <tr> <td> Pre_ObjectData_Descriptor::ObjectData_Size_Announced</td> <td class="ds">7:90</td> </tr> <tr> <td>Pre_ObjectData_Descriptor::Maximum_ObjectData_Size</td> <td class="ds">7:95</td> </tr> <tr> <td>ObjectData::Subfile</td> <td class="ds">8:10</td> </tr> <tr> <td> Post_ObjectData_Descriptor::Confirmed_ObjectData_Size</td> <td class="ds">9:10</td> </tr> </table> <h4>Example</h4> <pre> img.get_iptc_dataset(Magick::IPTC::Application::Keywords) </pre> <h4>Returns</h4> <p>The data field or nil</p> <h4>See also</h4> <p><a href= "image1.html#each_iptc_dataset">each_iptc_dataset</a>, <a href= "imageattrs.html#iptc_profile">iptc_profile</a></p> </div> <div class="sig"> <h3 id="get_pixels">get_pixels</h3> <p><span class="arg">image</span>.get_pixels(<span class= "arg">x</span>, <span class="arg">y</span>, <span class= "arg">columns</span>, <span class="arg">rows</span>) -> <em>anArray</em></p> </div> <div class="desc"> <h4>Description</h4> <p>Gets the pixels from the specified rectangle within the image.</p> <h4>Arguments</h4> <dl> <dt>x, y</dt> <dd>The x- and y-offset of the rectangle within the image.</dd> <dt>columns, rows</dt> <dd>The width and height of the rectangle.</dd> </dl> <h4>Returns</h4> <p>An array of <a href="struct.html#Pixel">pixels</a>. There will be <code>columns*rows</code> elements in the array.</p> <h4>Example</h4> <p>This example <a href="image1.html#composite">composites</a> a black-and-white version of an image over the same image in its original colors. It uses <code>get_pixels</code> and <a href="image3.html#store_pixels">store_pixels</a> to make each column of pixels in the black-and-white image slightly more opaque than the column on its left, so that the resulting composite changes smoothly from color on the left to black-and-white on the right.</p><!-- Reduce the size of the original image by specifying the size of the example image. --> <p class="rollover"><a href= "javascript:popup('get_pixels.rb.html')"><img width="384" height="249" onmouseover="this.src='ex/images/Red_Rocks.jpg'" onmouseout="this.src='ex/get_pixels.jpg'" src= "ex/get_pixels.jpg" title="Click to see the example script" alt="get_pixels example" /></a> <img src="ex/images/spin.gif" alt="" class="spin" style="left:388px" title= "Mouse over the example to see the original image" /></p> <h4>See also</h4> <p><a href="image3.html#store_pixels">store_pixels</a>, <a href="image3.html#view">view</a></p> <h4>Magick API</h4> <p>AcquireImagePixels</p> </div> <div class="sig"> <h3 id="gray_q">gray?</h3> <p><span class="arg">image</span>.gray? -> <code>true</code> or <code>false</code></p> </div> <div class="desc"> <h4>Description</h4> <p>Returns <code>true</code> if all the pixels in the image have the same red, green, and blue intensities.</p> <h4>Returns</h4> <p><code>true</code> or <code>false</code></p> <h4>See also</h4> <p><a href="#monochrome_q">monochrome?</a></p> <h4>Magick API</h4> <p>IsGrayImage</p> </div> <div class="sig"> <h3 id="grayscale_pseudo_class">grayscale_pseudo_class</h3> <p><span class= "arg">image</span>.grayscale_pseudo_class(<span class= "arg">optimize</span>=<code>true</code>) -> <em>anImage</em></p> </div> <div class="desc"> <h4>Description</h4> <p><span class="imquote">Converts an image to a PseudoClass grayscale representation with an optionally compressed and sorted colormap..</span> This method is only available in GraphicsMagick 1.1 and later.</p> <h4>Arguments</h4> <dl> <dt>optimize</dt> <dd>If true, compress and sort the colormap by increasing intensity.</dd> </dl> <h4>Returns</h4> <p>A new image</p> <h4>Magick API</h4> <p>GrayscalePseudoClass</p> </div> <div class="sig"> <h3 id="grey_q">grey?</h3> <p><span class="arg">image</span>.qrey? -> <code>true</code> or <code>false</code></p> </div> <div class="desc"> <h4>Description</h4> <p>Synonym for <a href="#gray_q">gray?</a></p> </div> <div class="sig"> <h3 id="implode">implode</h3> <p><span class="arg">image</span>.implode(<span class= "arg">amount</span>=0.50) -> <em>anImage</em></p> </div> <div class="desc"> <h4>Description</h4> <p>A funhouse mirror effect. See the example below.</p> <h4>Arguments</h4> <p>A <code>Float</code> value. Increasing the absolute value of the argument increases the effect. The value may be positive for implosion, or negative for explosion. The default is 0.50.</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('implode.rb.html')"><img onmouseover= "this.src='ex/implode.gif'" onmouseout= "this.src='ex/images/Flower_Hat.jpg'" src= "ex/images/Flower_Hat.jpg" alt="implode 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>ImplodeImage</p> </div> <div class="sig"> <h3 id="import_pixels">import_pixels</h3> <p><span class="arg">image</span>.import_pixels(<span class= "arg">x</span>, <span class="arg">y</span>, <span class= "arg">columns</span>, <span class="arg">rows</span>, <span class="arg">map</span>, <span class="arg">pixels</span>, <span class="arg">type</span>=Magick::CharPixel) -> <em>image</em></p> </div> <div class="desc"> <h4>Description</h4> <p>Replaces the pixels in the specified rectangle with pixel data from the supplied array or string. When the <span class= "arg">pixels</span> argument is an array of pixel data, this method is the reverse of <code>export_pixels</code>. When the <span class="arg">pixels</span> argument is a string, <code>import_pixels</code> is ideal for loading very large amounts of binary pixel data.</p> <h4>Arguments</h4> <dl> <dt>x, y</dt> <dd>The offset of the rectangle from the upper-left corner of the image</dd> <dt>columns, rows</dt> <dd>The width and height of the rectangle</dd> <dt>map</dt> <dd>A string describing <span class="imquote">the expected ordering of the pixel array. It can be any combination or order of R = red, G = green, B = blue, A = alpha, C = cyan, Y = yellow, M = magenta, K = black, or I = intensity (for grayscale).</span></dd> <dt>pixels</dt> <dd> The pixel data. Pixel data can be supplied as an array or as a string. <dl> <dt>If <span class="arg">pixels</span> responds to <code>:to_str</code></dt> <dd><code>import_pixels</code> assumes that <span class= "arg">pixels</span> can be converted to a string by <code>to_str</code> and that the result is a C array of the type specified by <span class="arg">type</span> containing binary pixel data in the order specified by <span class="arg">map</span>. The elements in the buffer must be in the range specified by <span class= "arg">type</span>.</dd> <dt>Otherwise</dt> <dd><code>import_pixels</code> assumes that <span class= "arg">pixels</span> is an array or an object that can be converted to an array by the <code>Kernel::Array</code> method. The elements in the array must be <code>Numeric</code> values in the range [0..MaxRGB]. In either case, the pixel data must be stored in scanline order: left-to-right and top-to-bottom.</dd> </dl> </dd> <dt>type</dt> <dd>A <a href="constants.html#StorageType">StorageType</a> value that specifies the type and range of the pixel data when <span class="arg">pixels</span> is a string.</dd> </dl> <h4>Returns</h4> <p>The image as transformed by the pixel data.</p> <h4>Example</h4> <pre> # Replace the r'th scanline of the image using # pixel data stored in red-green-blue order. img.import_pixels(0, r, img.columns, 1, "RGB", scanline); </pre> <h4>Example</h4> <p>This example is contrived since there's no need to convert the <code>pixels</code> array into a string by calling <code>pack</code>, but it does demonstrate the use of a string <span class="arg">pixels</span> argument. Note that this example assumes that ×Magick is configured with QuantumDepth=8.</p> <pre> hat = Magick::Image.read("Flower_Hat.jpg").first pixels = hat.export_pixels(0, 0, hat.columns, hat.rows, "RGB") char_buffer = pixels.pack("C*") img = Magick::Image.new(hat.columns, hat.rows) img.import_pixels(0, 0, hat.columns, hat.rows, "RGB", char_buffer, Magick::CharPixel) </pre> <h4>See also</h4> <p><a href="image1.html#constitute">constitute</a>, <a href= "#export_pixels">export_pixels</a>, <a href= "image3.html#store_pixels">store_pixels</a></p> <h4>Magick API</h4> <p>ImportImagePixels</p> <h4>Note</h4> <p>This method replaces the <code>constitute</code> method.</p> </div> <div class="sig"> <h3 id="inspect">inspect</h3> <p><span class="arg">image</span>.inspect -> <em>aString</em></p> </div> <div class="desc"> <h4>Description</h4> <p>Constructs a description of the image as a string. The string contains some or all of the following fields:</p> <dl> <dt>original_filename=></dt> <dd>if different from the current filename.</dd> <dt>filename</dt> <dd>the current filename</dd> <dt>[scene]</dt> <dd>the scene number, if the image is part of an image sequence</dd> <dt>format</dt> <dd>the image format (GIF or JPEG, for example)</dd> <dt>original width x height</dt> <dd>if different from the current width x height</dd> <dt>page width x height + x-offset + y-offset</dt> <dd>if any of these fields is non-zero</dd> <dt>storage class</dt> <dd><em>DirectClass</em> or <em>PseudoClass</em></dd> <dt>number of colors</dt> <dd>total number of colors used in the image</dd> <dt>mean error per pixel/normalized mean error/normalized maximum error</dt> <dd>for PseudoClass images, if present</dd> <dt><em>N</em>-bit</dt> <dd>bit depth</dd> <dt>blob size</dt> <dd>if present</dd> </dl> <h4>Example</h4> <pre> f.inspect » "images/Flower_Hat.jpg JPEG 200x250 DirectClass 8-bit 9kb" </pre> </div> <div class="sig"> <h3 id="level">level</h3> <p><span class="arg">image</span>.level(<span class= "arg">black_point</span>=<code>0.0</code>, <span class= "arg">white_point</span>=<code>MaxRGB</code>, <span class= "arg">gamma</span>=<code>1.0</code>) -> <em>anImage</em></p> </div> <div class="desc"> <h4>Description</h4> <p class="imquote">Adjusts the levels of an image by scaling the colors falling between specified white and black points to the full available quantum range. The parameters provided represent the black, mid, and white points. The black point specifies the darkest color in the image. Colors darker than the black point are set to zero. Gamma specifies a gamma correction to apply to the image. White point specifies the lightest color in the image. Colors brighter than the white point are set to the maximum quantum value</p> <h4>Arguments</h4> <dl> <dt>black_point</dt> <dd>A black point level in the range 0-<a href= "constants.html#Miscellaneous_constants">MaxRGB</a>. The default is 0.0.</dd> <dt>mid_point</dt> <dd>A white point level in the range 0-MaxRGB. The default is <a href="constants.html#Miscellaneous_constants">MaxRGB</a> - <span class="arg">black_point</span>.</dd> <dt>gamma</dt> <dd>A gamma correction in the range 0.0-10.0 The default is 1.0.</dd> </dl> <h4>Returns</h4> <p>A new image</p> <h4>Example</h4> <p><code>level(0,1.50)</code></p> <p class="rollover"><a href= "javascript:popup('level.rb.html')"><img onmouseover= "this.src='ex/images/Flower_Hat.jpg'" onmouseout= "this.src='ex/level.jpg'" src="ex/level.jpg" title= "Click to see the example script" alt="level example" /></a> <img src="ex/images/spin.gif" alt="" class="spin" title= "Mouse over the image to see the original image" /></p> <h4>Compatibility notes</h4> <p>Prior to version 1.11.0 RMagick defined the signature for <code>level</code> incorrectly:</p> <pre> img.level(white_point, gamma, black_point) -> anImage # wrong! </pre> <p>That is, the <code>gamma</code> and <code>white_point</code> arguments were swapped. In an effort to maintain compatibility with older scripts that expect that signature, <code>level</code> inspects its arguments and will interchange <code>white_point</code> and gamma if they "look" incorrect. That is, if <code>gamma</code> is > 10.0, or if <code>white_point</code> is < 10.0, or if <code>gamma</code> > <code>white_point</code>, then <code>level</code> will swap them.</p> <p>If you want to avoid this behavior, use the <code>level2</code> method instead. The <code>level2</code> method is exactly the same as <code>level</code> except that it never swaps the arguments.</p> <h4>See also</h4> <p><a href="#level_channel">level_channel</a></p> <h4>Magick API</h4> <p>LevelImage</p> </div> <div class="sig"> <h3 id="level_channel">level_channel</h3> <p><span class="arg">image</span>.level_channel(<span class= "arg">channel</span>, <span class="arg">black_point</span>=0, <span class="arg">white_point</span>=MaxRGB - black_point, <span class="arg">gamma</span>=1.0) -> <em>anImage</em></p> </div> <div class="desc"> <h4>Description</h4>Same as level but operates only on the specified channel. <h4>Arguments</h4> <dl> <dt>channel</dt> <dd>A <a href="constants.html#ChannelType">ChannelType</a> value.</dd> <dt>black_point</dt> <dd>A black point level in the range 0-<a href= "constants.html#Miscellaneous_constants">MaxRGB</a>. The default is 0.0.</dd> <dt>mid_point</dt> <dd>A white point level in the range 0-MaxRGB. The default is <a href="constants.html#Miscellaneous_constants">MaxRGB</a> - <span class="arg">black_point</span>.</dd> <dt>gamma</dt> <dd>A gamma correction in the range 0.0-10.0 The default is 1.0.</dd> </dl> <h4>Returns</h4> <p>A new image</p> <h4>See also</h4> <p><a href="#level">level</a></p> <h4>Magick API</h4> <p>LevelImageChannel</p> </div> <div class="sig"> <h3 id="linear_stretch">linear_stretch</h3> <p><span class="arg">image</span>.linear_stretch(<span class= "arg">black_point</span>[, <span class= "arg">white_point</span>]) -> <em>anImage</em></p> </div> <div class="desc"> <h4>Description</h4> <p class="imquote">Linear with saturation stretch.</p> <h4>Arguments</h4> <dl> <dt>black_point</dt> <dd>black out at most this many pixels. Specify an absolute number of pixels as a numeric value, or a percentage as a string in the form 'NN%'.</dd> <dt>white_point</dt> <dd>burn at most this many pixels. Specify an absolute number of pixels as a numeric value, or a percentage as a string in the form 'NN%'. This argument is optional. If not specified the default is <code>all pixels - black_point pixels</code>.</dd> </dl> <h4>Returns</h4> <p>A new image</p> <h4>Magick API</h4> <p>LinearStretchImage</p> </div> <div class="sig"> <h3 id="magnify">magnify</h3> <p><span class="arg">image</span>.magnify -> <em>anImage</em></p> </div> <div class="desc"> <h4>Description</h4> <p>A convenience method that scales the receiver to twice its size.</p> <h4>Returns</h4> <p>A new image</p> <h4>See also</h4> <p><a href="#magnify_bang">magnify!</a>, <a href= "#minify">minify</a>, <a href="image3.html#resize">resize</a>, <a href="image3.html#scale">scale</a></p> <h4>Magick API</h4> <p>MagnifyImage</p> </div> <div class="sig"> <h3 id="magnify_bang">magnify!</h3> <p><span class="arg">image</span>.magnify! -> <em>image</em></p> </div> <div class="desc"> <h4>Description</h4> <p>In-place form of <a href="#magnify">magnify</a></p> <h4>Returns</h4>self </div> <div class="sig"> <h3 id="map">map</h3> <p><span class="arg">image</span>.map(<span class= "arg">img</span>, <span class="arg">dither</span>=false) -> <em>anImage</em></p> </div> <div class="desc"> <h4>Description</h4> <p class="imquote">Replaces the colors of an image with the closest color from a reference image.</p> <h4>Arguments</h4> <dl> <dt>img</dt> <dd>The reference image. May be either another image or an Image object.</dd> <dt>dither</dt> <dd>If true, dithers the mapped image.</dd> </dl> <h4>Returns</h4> <p>A new image</p> <h4>Example</h4> <p>This image has been mapped to the Netscape 216-color cube.</p> <p class="rollover"><a href= "javascript:popup('map_f.rb.html')"><img onmouseover= "this.src='ex/images/Flower_Hat.jpg'" onmouseout= "this.src='ex/map_f.jpg'" src="ex/map_f.jpg" alt= "map_f 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="ilist.html#map">ImageList#map</a></p> <h4>Magick API</h4> <p>MapImage</p> </div> <div class="sig"> <h3 id="matte_fill_to_border">matte_fill_to_border</h3> <p><span class= "arg">image</span>.matte_fill_to_border(<span class= "arg">x</span>, <span class="arg">y</span>) -> <em>anImage</em></p> </div> <div class="desc"> <h4>Description</h4> <p>Makes transparent all the pixels that are neighbors of the pixel at <span class="arg">x</span>,<span class="arg">y</span> and are not the border color.</p> <h4>Arguments</h4> <p>The x- and y- coordinates of the target pixel.</p> <h4>Returns</h4> <p>A new image</p> <h4>Example</h4> <p>In this example the border color is black. The fill starts in the center and makes all the pixels transparent until it reaches a black pixel. The resulting image has been composited over a plasma background, which shows through the transparent pixels.</p> <p class="rollover"><a href= "javascript:popup('matte_fill_to_border.rb.html')"><img src= "ex/matte_fill_to_border_after.gif" onmouseover= "this.src='ex/matte_fill_to_border_before.gif'" onmouseout= "this.src='ex/matte_fill_to_border_after.gif'" alt= "matte_fill_to_border 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="#matte_floodfill">matte_floodfill</a>, <a href= "draw.html#matte">Draw#matte</a></p> <h4>Magick API</h4> <p>MatteFloodfillImage</p> </div> <div class="sig"> <h3 id="matte_floodfill">matte_floodfill</h3> <p><span class="arg">image</span>.matte_floodfill(<span class= "arg">x</span>, <span class="arg">y</span>) -> <em>anImage</em></p> </div> <div class="desc"> <h4>Description</h4> <p>Makes transparent all the pixels that are the same color as the pixel at <span class="arg">x</span>, <span class= "arg">y</span>, and are neighbors.</p> <h4>Arguments</h4> <p>The x- and y-coordinates of the target pixel.</p> <h4>Returns</h4> <p>A new image</p> <h4>Example</h4> <p>In this example the fill starts at the center pixel and replaces all the yellow pixels - the color of the center pixel. The resulting image has been composited over a plasma background, which shows through the transparent pixels.</p> <p class="rollover"><a href= "javascript:popup('matte_floodfill.rb.html')"><img src= "ex/matte_floodfill_after.gif" onmouseover= "this.src='ex/matte_floodfill_before.gif'" onmouseout= "this.src='ex/matte_floodfill_after.gif'" alt= "matte_floodfill 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="#matte_replace">matte_replace</a>, <a href= "draw.html#matte">Draw#matte</a></p> <h4>Magick API</h4> <p>MatteFloodfilImage</p> </div> <div class="sig"> <h3 id="matte_point">matte_point</h3> <p><span class="arg">image</span>.matte_point(<span class= "arg">x</span>, <span class="arg">y</span>) -> <em>anImage</em></p> </div> <div class="desc"> <h4>Description</h4> <p>Makes the pixel at <span class="arg">x</span>, <span class= "arg">y</span> transparent. This method makes a copy of the image, just to make one pixel transparent. I recommend using the Draw#matte method instead.</p> <h4>Arguments</h4> <p>The x- and y-coordinates of the target pixel.</p> <h4>Returns</h4> <p>A new image</p> <h4>See also</h4> <p><a href="draw.html#matte">Draw#matte</a></p> </div> <div class="sig"> <h3 id="matte_replace">matte_replace</h3> <p><span class="arg">image</span>.matte_replace(<span class= "arg">x</span>, <span class="arg">y</span>) -> <em>anImage</em></p> </div> <div class="desc"> <h4>Description</h4> <p>Makes transparent all the pixels that are the same color as the pixel at <span class="arg">x</span>, <span class= "arg">y</span>.</p> <h4>Arguments</h4>The x- and y-coordinates of the target pixel. <h4>Returns</h4> <p>A new image</p> <h4>Example</h4> <p>In this example the target pixel is a black pixel in the center of the uppermost circle. The matte_replace method makes all the black pixels in the image 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('matte_replace.rb.html')"><img onmouseover= "this.src='ex/matte_replace_before.gif'" onmouseout= "this.src='ex/matte_replace_after.gif'" src= "ex/matte_replace_after.gif" alt="matte_replace 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="image3.html#transparent">transparent</a>, <a href= "draw.html#matte">Draw#matte</a></p> <h4>Magick API</h4> <p>TransparentImage</p> </div> <div class="sig"> <h3 id="matte_reset_bang">matte_reset!</h3> <p><span class="arg">image</span>.matte_reset! -> <em>image</em></p> </div> <div class="desc"> <h4>Description</h4> <p>Makes all the pixels in the image transparent.</p> <h4>Returns</h4> <p>self</p> <h4>See also</h4> <p><a href="imageattrs.html#opacity">opacity=</a></p> <h4>Magick API</h4>SetImageOpacity </div> <div class="sig"> <h3 id="median_filter">median_filter</h3> <p><span class="arg">image</span>.median_filter(<span class= "arg">radius</span>=1.0) -> <em>anImage</em></p> </div> <div class="desc"> <h4>Description</h4> <p class="imquote">Applies a digital filter that improves the quality of a noisy image. Each pixel is replaced by the median in a set of neighboring pixels as defined by radius.</p> <h4>Arguments</h4> <p>The filter radius. The larger the value, the longer it takes to render. Values larger than 8 or 9 may take longer than you want to wait, and will not have significantly better results than much smaller values.</p> <h4>Returns</h4> <p>A new image</p> <h4>Example</h4> <p>The left side of the image has been modified by <a href= "image1.html#add_noise">add_noise</a>. The right side has been filtered by median_filter(0.05).</p> <p><a href= "javascript:popup('median_filter.rb.html')"><img src="ex/median_filter.jpg" alt="median_filter example" /></a></p> <h4>See also</h4> <p><a href="#enhance">enhance</a>, <a href= "image3.html#reduce_noise">reduce_noise</a>, <a href= "image3.html#unsharp_mask">unsharp_mask</a></p> <h4>Magick API</h4> <p>MedianFilterImage</p> </div> <div class="sig"> <h3 id="minify">minify</h3> <p><span class="arg">image</span>.minify -> <em>anImage</em></p> </div> <div class="desc"> <h4>Description</h4> <p>A convenience method that scales the receiver to half its size.</p> <h4>Returns</h4> <p>A new image</p> <h4>See also</h4> <p><a href="#minify_bang">minify!</a> <a href= "#magnify">magnify</a>, <a href= "image3.html#resize">resize</a>, <a href= "image3.html#sample">sample</a>, <a href= "image3.html#scale">scale</a>, <a href= "image3.html#thumbnail">thumbnail</a></p> <h4>Magick API</h4> <p>MinifyImage</p> </div> <div class="sig"> <h3 id="minify_bang">minify!</h3> <p><span class="arg">image</span>.minify! -> <em>image</em></p> </div> <div class="desc"> <h4>Description</h4> <p>In-place form of <a href="#minify">minify</a>.</p> <h4>Returns</h4> <p>self</p> </div> <div class="sig"> <h3 id="modulate">modulate</h3> <p><span class="arg">image</span>.modulate(<span class= "arg">brightness</span>=1.0, <span class= "arg">saturation</span>=1.0, <span class="arg">hue</span>=1.0) -> <em>anImage</em></p> </div> <div class="desc"> <h4>Description</h4> <p>Changes the brightness, saturation, and hue.</p> <h4>Arguments</h4> <p>The percent change in the brightness, saturation, and hue, represented as Float numbers. For example, 0.25 means "25%". All three arguments may be omitted. The default value of each argument is 1.0, that is, 100%.</p> <h4>Returns</h4> <p>A new image</p> <h4>Example</h4> <p>modulate(0.85)</p> <p class="rollover"><a href= "javascript:popup('modulate.rb.html')"><img src= "ex/modulate.jpg" alt="modulate example" onmouseover= "this.src='ex/images/Flower_Hat.jpg'" onmouseout= "this.src='ex/modulate.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>ModulateImage</p> </div> <div class="sig"> <h3 id="monochrome_q">monochrome?</h3> <p><span class="arg">image</span>.monochrome? -> true or false</p> </div> <div class="desc"> <h4>Description</h4> <p>Returns true if all the pixels have the same red, green, and blue values and the values are either 0 or MaxRGB. That is, the image is black-and-white.</p> <h4>See also</h4> <p><a href="#gray_q">gray?</a></p> <h4>Magick API</h4> <p>IsMonochromeImage</p> </div> <div class="sig"> <h3 id="motion_blur">motion_blur</h3> <p><span class="arg">image</span>.motion_blur(<span class= "arg">radius</span>=0.0, <span class="arg">sigma</span>=1.0, <span class="arg">angle</span>=0.0) -> <em>anImage</em></p> </div> <div class="desc"> <h4>Description</h4> <p class="imquote">Simulates motion blur. We convolve the image with a Gaussian operator of the given <span class= "arg">radius</span> and standard deviation (<span class= "arg">sigma</span>). Use a radius of 0 and motion_blur selects a suitable radius for you. <span class="arg">Angle</span> gives the angle of the blurring motion.</p> <h4>Arguments</h4> <dl> <dt>radius</dt> <dd>The radius of the Gaussian operator.</dd> <dt>sigma</dt> <dd>The standard deviation of the Gaussian operator. Must be non-0.</dd> <dt>angle</dt> <dd>The angle (in degrees) of the blurring motion.</dd> </dl> <h4>Returns</h4> <p>A new image</p> <h4>Example</h4> <p class="rollover"><a href= "javascript:popup('motion_blur.rb.html')"><img src= "ex/motion_blur.jpg" alt="motion_blur example" title= "Click to see the example script" onmouseover= "this.src='ex/images/Flower_Hat.jpg'" onmouseout= "this.src='ex/motion_blur.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#blur_image">blur_image</a>, <a href= "#gaussian_blur">gaussian_blur</a></p> <h4>Magick API</h4> <p>MotionBlurImage</p> </div> <div class="sig"> <h3 id="negate">negate</h3> <p><span class="arg">image</span>.negate(<span class= "arg">grayscale</span>=false) -> <em>anImage</em></p> </div> <div class="desc"> <h4>Description</h4> <p>Negates the colors in the receiver.</p> <h4>Arguments</h4>If the <span class="arg">grayscale</span> argument is true, only the grayscale values are negated. <h4>Returns</h4> <p>A new image</p> <h4>Example</h4> <p class="rollover"><a href= "javascript:popup('negate.rb.html')"><img src="ex/negate.jpg" alt="negate example" onmouseover= "this.src='ex/images/Flower_Hat.jpg'" onmouseout= "this.src='ex/negate.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="#negate_channel">negate_channel</a></p> <h4>Magick API</h4> <p>NegateImage</p> </div> <div class="sig"> <h3 id="negate_channel">negate_channel</h3> <p><span class="arg">image</span>.negate_channel(<span class= "arg">grayscale</span>=false, [<span class= "arg">channel</span>...]) = <em>anImage</em></p> </div> <div class="desc"> <h4>Description</h4> <p>Negate a particular image channel or channels.</p> <h4>Arguments</h4> <dl> <dt>grayscale</dt> <dd class="imquote">if true, only negate grayscale pixels within the image</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 negated. Specifying no channel arguments has the same effect as the negate method, above.</dd> </dl> <h4>Returns</h4> <p>A new image</p> <h4>Example</h4> <p>negate_channel(false, GreenChannel)</p> <p class="rollover"><a href= "javascript:popup('negate_channel.rb.html')"><img src= "ex/negate_channel.jpg" alt="negate_channel example" onmouseover="this.src='ex/images/Flower_Hat.jpg'" onmouseout= "this.src='ex/negate_channel.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="#negate">negate</a></p>. <h4>Magick API</h4> <p>NegateImageChannel</p> </div> <div class="sig"> <h3 id="normalize">normalize</h3> <p><span class="arg">image</span>.normalize -> <em>anImage</em></p> </div> <div class="desc"> <h4>Description</h4> <p class="imquote">Enhances the contrast of a color image by adjusting the pixel color to span the entire range of colors available.</p> <h4>Returns</h4> <p>A new image</p> <h4>Example</h4> <p class="rollover"><a href= "javascript:popup('normalize.rb.html')"><img src= "ex/normalize.jpg" alt="normalize example" title= "Click to see the example script" onmouseover= "this.src='ex/images/Hot_Air_Balloons.jpg'" onmouseout= "this.src='ex/normalize.jpg'" /></a> <img src= "ex/images/spin.gif" alt="" class="spin" style="left: 191px;" title="Mouse over the example to see the original image" /></p> <h4>Magick API</h4> <p>NormalizeImage</p> <h4>See also</h4> <p><a href="#normalize_channel">normalize_channel</a></p> </div> <div class="sig"> <h3 id="normalize_channel">normalize_channel</h3> <p><span class= "arg">image</span>.normalize_channel([<span class= "arg">channel</span>...]) = <em>anImage</em></p> </div> <div class="desc"> <h4>Description</h4> <p><span class="imquote">Enhances the contrast of a color image by adjusting the pixel color to span the entire range of colors available.</span> Only the specified channels are normalized.</p> <h4>Arguments</h4> <dl> <dt>channel...</dt> <dd>0 or more <a href= "constants.html#ChannelType">ChannelType</a> arguments. If no channels are specified, all the channels are normalized. Specifying no channel arguments has the same effect as the normalize method, above.</dd> </dl> <h4>Returns</h4> <p>A new image</p> <h4>Magick API</h4> <p>NormalizeImageChannel (available in ImageMagick 6.1.0)</p> <h4>See also</h4> <p><a href="#normalize">normalize</a></p> </div> <div class="sig"> <h3 id="oil_paint">oil_paint</h3> <p><span class="arg">image</span>.oil_paint(<span class= "arg">radius</span>=3.0) -> <em>anImage</em></p> </div> <div class="desc"> <h4>Description</h4> <p class="imquote">Applies a special effect filter that simulates an oil painting. Each pixel is replaced by the most frequent color occurring in a circular region defined by <span class="arg">radius</span>.</p> <h4>Returns</h4> <p>A new image</p> <h4>Example</h4> <p class="rollover"><a href= "javascript:('oil_paint.rb.html')"><img src="ex/oil_paint.jpg" title="Click to see the example script" onmouseover= "this.src='ex/images/Flower_Hat.jpg'" onmouseout= "this.src='ex/oil_paint.jpg'" alt="oil_paint 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>OilPaintImage</p> </div> <div class="sig"> <h3 id="opaque">opaque</h3> <p><span class="arg">image</span>.opaque(<span class= "arg">target</span>, <span class="arg">fill</span>) -> <em>anImage</em></p> </div> <div class="desc"> <h4>Description</h4> <p>Changes all pixels having the target color to the fill color.</p> <h4>Arguments</h4> <dl> <dt>target</dt> <dd>The color to be replaced. May be a color name or a <a href="struct.html#Pixel">Pixel</a></dd> <dt>fill</dt> <dd>The replacement color. May be a color name or a <a href= "struct.html#Pixel">Pixel</a></dd> </dl> <h4>Returns</h4> <p>A new image</p> <h4>Example</h4> <pre> img.fuzz = 25 img = img.opaque('white', 'red') </pre> <h4>See also</h4> <p><a href="image1.html#color_floodfill">color_floodfill</a></p> <h4>Magick API</h4> <p>OpaqueImage</p> </div> <div class="sig"> <h3 id="opaque_q">opaque?</h3> <p><span class="arg">image</span>.opaque? -> true or false</p> </div> <div class="desc"> <h4>Description</h4> <p>Returns true if all of the pixels in the receiver have an opacity value of <a href= "constants.html#Opacity">OpaqueOpacity</a>.</p> <h4>Returns</h4> <p>true or false</p> <h4>Magick API</h4> <p>IsOpaqueImage</p> </div> <div class="sig"> <h3 id="ordered_dither">ordered_dither</h3> <p><span class="arg">image</span>.ordered_dither(<span class= "arg">threshold_map</span>='2x2') -> <em>anImage</em></p> </div> <div class="desc"> <h4>Description</h4> <p>Dithers the image to a predefined pattern. The <span class= "arg">threshold_map</span> argument defines the pattern to use.</p> <h4>Arguments</h4> <p>The <span class="arg">threshold_map</span> argument can be any of the strings listed by this command:</p> <pre> convert -list Thresholds </pre> <p>GraphicsMagick and older releases of ImageMagick do not accept threshold map strings and will not respond to that command. In these cases <span class="arg">threshold_map</span> should be one of the numbers 2, 3, or 4. These numbers correspond to the threshold maps "o2x2", "o3x3", and "o4x4", respectively.</p> <h4>Returns</h4> <p>A new image</p> <h4>Example</h4> <p class="rollover"><a href= "javascript:popup('ordered_dither.rb.html')"><img src= "ex/ordered_dither.jpg" alt="ordered_dither example" onmouseover="this.src='ex/images/Flower_Hat.jpg'" onmouseout= "this.src='ex/ordered_dither.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="#posterize">posterize</a>, <a href= "image3.html#quantize">quantize</a></p> <h4>Magick API</h4> <p>OrderedPosterizeImage</p> </div> <div class="sig"> <h3 id="palette_q">palette?</h3> <p><span class="arg">image</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">image</span>.pixel_color(<span class= "arg">x</span>, <span class="arg">y</span>[, <span class= "arg">new_color</span>]) -> <em>aPixel</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>image.polaroid(angle=-5.0) [ <span class="arg">{ optional arguments }</span> ] -> anImage</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>. The argument can be either a <a href="imusage.html#color_names">color name</a> or a <a href= "struct.html#Pixel">Pixel</a>.</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> <p>Polaroid is a registered trademark of the Polaroid Corporation.</p> <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 (introduced in ImageMagick 6.3.1)</p> <h4>See also</h4> <p><a href= "http://rmagick.rubyforge.org/Polaroid/polaroid.html">The Polaroid Effect</a></p> </div> <div class="sig"> <h3 id="posterize">posterize</h3> <p><span class="arg">image</span>.posterize(<span class= "arg">levels</span>=4, <span class="arg">dither</span>=false) -> <em>anImage</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="#ordered_dither">ordered_dither</a>, <a href= "image3.html#quantize">quantize</a></p> <h4>Magick API</h4> <p>PosterizeImage</p> </div> <p class="spacer"> </p> <div class="nav"> « <a href="image1.html">Prev</a> | <a href= "index.html">Contents</a> | <a href= "image3.html">Next</a> » </div> </body> </html>