<!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 March 2005), see www.w3.org" />

  <title>RMagick: class ImageList</title>
  <meta http-equiv="Content-Type" content=
  "text/html; charset=us-ascii" />
  <meta name="GENERATOR" content="Quanta Plus" />
  <meta name="Copyright" content=
  "Copyright (C) 2005 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 these images -->
    img = new Image();
    img.src = "ex/average_before.gif";
    img.src = "ex/coalesce_anim.gif";
    img.src = "ex/map_before.jpg";
    img.src = "ex/morph.gif";
    img.src = "ex/quantize-m_before.jpg";
  //]]>
</script>
<style type="text/css">
  /*<![CDATA[*/

  /* Styles local to this page. */
  /*]]>*/
</style>
</head>

<body>
  <h6 id="header">RMagick User's Guide and Reference</h6>

  <div class="nav">
    &laquo;&nbsp;<a href="magick.html">Prev</a> | <a href=
    "index.html">Contents</a> | <a href=
    "imageattrs.html">Next</a>&nbsp;&raquo;
  </div>

  <h1>class ImageList <span class="superclass">&lt;
  Array</span><br />
  <span class="mixin">mixes in Comparable</span></h1>

  <div id="toc">
    <h2>Table of Contents</h2>

    <h3>class methods</h3>

    <ul>
      <li><a href="#new">new</a></li>
    </ul>

    <h3>attributes</h3>

    <ul>
      <li><a href="#delay_eq">delay=</a></li>

      <li><a href="#iterations_eq">iterations=</a></li>

      <li><a href="#length">length</a></li>

      <li><a href="#scene">scene, scene=</a></li>

      <li><a href="#ticks_per_second_eq">ticks_per_second=</a></li>
    </ul>

    <h3>instance methods</h3>

    <div class="toccol">
      <ul>
        <li><a href="#array_methods">Array methods</a></li>

        <li><a href="#spaceship">&lt;=&gt;</a></li>

        <li><a href="#animate">animate</a></li>

        <li><a href="#append">append</a></li>

        <li><a href="#average">average</a></li>

        <li><a href="#clone">clone</a></li>

        <li><a href="#coalesce">coalesce</a></li>

        <li><a href="#copy">copy</a></li>

        <li><a href="#cur_image">cur_image</a></li>
      </ul>
    </div>

    <div class="toccol">
      <ul>
        <li><a href="#deconstruct">deconstruct</a></li>

        <li><a href="#dup">dup</a></li>

        <li><a href="#display">display</a></li>

        <li><a href="#flatten_images">flatten_images</a></li>

        <li><a href="#from_blob">from_blob</a></li>

        <li><a href="#inspect">inspect</a></li>

        <li><a href="#map">map</a></li>

        <li><a href="#montage">montage</a></li>
      </ul>
    </div>

    <div class="toccol">
      <ul>
        <li><a href="#morph">morph</a></li>

        <li><a href="#mosaic">mosaic</a></li>

        <li><a href="#new_image">new_image</a></li>

        <li><a href="#ping">ping</a></li>

        <li><a href="#quantize">quantize</a></li>

        <li><a href="#read">read</a></li>

        <li><a href="#to_blob">to_blob</a></li>

        <li><a href="#write">write</a></li>
      </ul>
    </div>
  </div>

  <h2 class="methods">class methods</h2>

  <div class="sig">
    <h3 id="new">new</h3>

    <p>Magick::ImageList.new -&gt; <em>imagelist</em><br />
    Magick::ImageList.new(<span class="arg">filename[,
    filename...]]</span>) -&gt; <em>imagelist</em></p>
  </div>

  <div class="desc">
    <h4>Description</h4>

    <p>Creates a new imagelist. If one or more image filenames are
    specified, opens and reads the files, adding a new image for
    each image in the image file(s). Sets the scene number to the
    index of the last image, or <code>nil</code> if no filenames
    are specified.</p>

    <h4>Arguments</h4>

    <p>Zero or more image file names.</p>

    <h4>Returns</h4>

    <p>A new imagelist. The imagelist contains an Image object for
    each image in the specified files. A file can contain more than
    one image. For example, new will create an image for each frame
    in an animated GIF or each layer in a multi-layer Photoshop
    file.</p>

    <h4>Example</h4>
    <pre>
i = Magick::ImageList.new
i = Magick::ImageList.new("Button_A.gif", "Cheetah.jpg")
</pre>
  </div>

  <h2 class="methods">attributes</h2>

  <div class="sig">
    <h3 id="delay_eq">delay=</h3>

    <p><span class="arg">imagelist.</span>delay=<em>n</em></p>
  </div>

  <div class="desc">
    <h4>Description</h4>

    <p>In conjunction with <a href=
    "#ticks_per_second_eq">ticks_per_second</a> sets the length of
    time between each image in an animation. The
    <code>delay=</code> attribute assigns the same delay to all the
    images in the imagelist. Use <a href=
    "imageattrs.html#Image.delay">Image#delay=</a> to set different
    delay values on individual images.</p>

    <h4>Arguments</h4>

    <p>An integer value representing the number of ticks that must
    elapse between each image in an animation.</p>

    <h4>Returns</h4>

    <p>self</p>

    <h4>Example</h4>
    <pre>
imagelist.delay = 20 # delay 1/5 of a second between images.
</pre>

    <h4>See also</h4>

    <p><a href="imageattrs.html#Image.delay">Image#delay=</a></p>
  </div>

  <div class="sig">
    <h3 id="iterations_eq">iterations=</h3>

    <p><span class="arg">imagelist.</span>iterations=<em>n</em></p>
  </div>

  <div class="desc">
    <h4>Description</h4>

    <p>Sets the number of times an animated image should loop.</p>

    <p>The <a href="#animate">animate</a> method and the
    ImageMagick animate/GraphicsMagick gm utilities do not respect
    this number. Both will repeat the animation until you stop
    them. Mozilla (and presumably Netscape) do respect the
    value..</p>

    <h4>Arguments</h4>

    <p>The number of iterations.</p>

    <h4>Returns</h4>

    <p>self</p>

    <h4>Example</h4>
    <pre>
imagelist.iterations = 10
</pre>
  </div>

  <div class="sig">
    <h3 id="length">length</h3>

    <p><span class="arg">imagelist.</span>length -&gt;
    <em>anInteger</em></p>
  </div>

  <div class="desc">
    <h4>Description</h4>

    <p>Returns the number of images in the imagelist.</p>

    <h4>Example</h4>
    <pre>
i = Magick::ImageList.new("images/Button_A.gif", "images/Button_B.gif")
i.length &raquo; 2
</pre>
  </div>

  <div class="sig">
    <h3 id="scene">scene, scene=</h3>

    <p><span class="arg">imagelist</span>.scene -&gt;
    <em>anInteger</em><br />
    <span class="arg">imagelist</span>.scene =
    <em>anInteger</em></p>
  </div>

  <div class="desc">
    <h4>Description</h4>

    <p>Get/set the current <em>scene number</em>. The scene number
    indicates the image to which <a href="image1.html">Image</a>
    methods are sent.</p>

    <h4>Example</h4>
    <pre>
imagelist.scene = 10
imagelist.scene &raquo; 10
</pre>
  </div>

  <div class="sig">
    <h3 id="ticks_per_second_eq">ticks_per_second=</h3>

    <p><span class="arg">imagelist</span>.ticks_per_second =
    <em>anInteger</em></p>
  </div>

  <div class="desc">
    <h4>Description</h4>

    <p>Used in conjunction with <a href="#delay_eq">delay</a> to
    establish the elapsed time between frames in an animation. By
    default the number of ticks per second is 100.</p>

    <p>This attribute is available only in ImageMagick 6.2.4 and
    later. Prior to this release the number of ticks per second is
    fixed at 100.</p>

    <h4>Example</h4>
    <pre>
imagelist.ticks_per_second = 1000
</pre>
  </div>

  <h2 class="methods">instance methods</h2>

  <div class="sig">
    <h3 id="array_methods">Array methods</h3>

    <p>&nbsp;</p>
  </div>

  <div class="desc">
    <h4>Description</h4>

    <p><code>ImageList</code> is a subclass of <code>Array</code>,
    so you can manipulate the images in an imagelist using almost
    all of the methods defined in <code>Array</code>. Typically
    these methods also update the scene number. The scene number
    will never exceed the number of images in the list, and if the
    imagelist contains no images the scene number will be
    <code>nil</code>.</p>

    <p>Array methods defined in the ImageList class that would
    normally return an array return an ImageList.</p>

    <p>Most array methods keep the current image current. If the
    method moves the current image to a new position, the method
    updates the scene number to the new index. If the method
    deletes the current image, the scene number is set to the last
    image in the list. The following table lists the methods that
    do not follow these rules.</p>

    <table summary="array method affect on scene number" class=
    "simple_table">
      <caption>
        Array method behavior
      </caption>

      <thead>
        <tr>
          <th>Array method</th>

          <th>scene number will be...</th>
        </tr>
      </thead>

      <tbody>
        <tr>
          <td>&lt;&lt;</td>

          <td>set to index the last image in the list</td>
        </tr>

        <tr>
          <td>clear</td>

          <td>set to <code>nil</code></td>
        </tr>

        <tr>
          <td>concat</td>

          <td>set to index the last image in the list</td>
        </tr>

        <tr>
          <td>push</td>

          <td>set to index the last image in the list</td>
        </tr>

        <tr>
          <td>unshift</td>

          <td>set to 0</td>
        </tr>
      </tbody>
    </table>

    <p>Adding anything other than a image to an imagelist has
    undefined results. Most of the time RMagick will raise an
    ArgumentError exception.</p>

    <p>The <code>assoc</code>, <code>flatten</code>,
    <code>flatten!</code>, <code>join</code>, <code>pack</code>,
    and <code>rassoc</code> methods are not defined in the
    ImageList class.</p>

    <h4>Example</h4>

    <p>Add noise to a model image. Append the resulting image to
    the imagelist in "example". (See: <a href=
    "javascript:popup('demo.rb.html')">demo.rb</a>)</p>
    <pre>
example = Magick::ImageList.new
model = Magick::ImageList.new "model.miff"
example &lt;&lt; model.add_noise Magick::LaplacisanNoise
</pre>

    <h4>See also</h4>

    <p><a href="#scene">scene</a>, <a href="#scene">scene=</a></p>
  </div>

  <div class="sig">
    <h3 id="spaceship">&lt;=&gt;</h3>

    <p><span class="arg">imagelist</span> &lt;=&gt; <span class=
    "arg">anOtherImageList</span> -&gt; -1, 0, 1</p>
  </div>

  <div class="desc">
    <h4>Description</h4>

    <p>Compares two imagelists and returns -1, 0, or 1 if the
    receiver is less than, equal to, or greater than the other
    imagelist. The comparison between the receiver (a) and the
    other (b) is performed this way:</p>

    <ol>
      <li>For all images <code>n</code>, if the result of
      <code>a[n]&nbsp;&lt;=&gt;&nbsp;b[n]</code> is not 0 then that
      is the result of a&nbsp;&lt;=&gt;&nbsp;b. Individual images
      are compared by comparing their <a href=
      "image3.html#signature">signatures</a>.</li>

      <li>If <code>a.scene&nbsp;&lt;=&gt;&nbsp;b.scene</code> is
      not 0, returns the result</li>

      <li>Returns
      <code>a.length&nbsp;&lt;=&gt;&nbsp;b.length</code></li>
    </ol>

    <p><code>ImageList</code> mixes in the <code>Comparable</code>
    module.</p>

    <h4>See also</h4>

    <p><a href="image1.html#spaceship">Image#&lt;=&gt;</a>,
    <a href="image3.html#signature">signature</a></p>
  </div>

  <div class="sig">
    <h3 id="animate">animate</h3>

    <p><span class="arg">imagelist.</span>animate(<span class=
    "arg">[delay]</span>) <span class="arg">[&nbsp;{ optional
    arguments }&nbsp;]</span> -&gt; <em>self</em></p>
  </div>

  <div class="desc">
    <h4>Description</h4>

    <p>Animate the images to an X Window screen. By default
    displays to the local screen. You can specify a different
    screen by assigning the name to the <code>server_name</code>
    attribute in the optional arguments block.</p>

    <h4>Returns</h4>

    <p>self</p>

    <h4>Example</h4>
    <pre>
imagelist.animate
imagelist.animate { self.server_name = "other:0.0" }
</pre>

    <h4>See also</h4>

    <p><a href="#ImageList.display">display</a></p>

    <h4>Note</h4>

    <p>The animate method is not supported on native MS
    Windows.</p>

    <h4>Magick API</h4>

    <p>AnimateImages</p>
  </div>

  <div class="sig">
    <h3 id="append">append</h3>

    <p><span class="arg">imagelist.</span>append(<code>true</code>
    or <code>false</code>) -&gt; <em>anImage</em></p>
  </div>

  <div class="desc">
    <h4>Description</h4>

    <p>Append all the images in the imagelist, either vertically or
    horizontally. If the images are not of the same width, any
    narrow images will be expanded to fit using the background
    color.</p>

    <h4>Arguments</h4>

    <p>If <code>true</code>, rectangular images are stacked
    top-to-bottom, otherwise left-to-right.</p>

    <h4>Returns</h4>

    <p>A image composed of all the images in the imagelist.</p>

    <h4>Example</h4>

    <p>See the <a href="#ImageList.map">map</a> example.</p>

    <h4>Magick API</h4>

    <p>AppendImages</p>
  </div>

  <div class="sig">
    <h3 id="average">average</h3>

    <p><span class="arg">imagelist.</span>average -&gt;
    <em>anImage</em></p>
  </div>

  <div class="desc">
    <h4>Description</h4>

    <p>Averages all the images together. Each image in the image
    must have the same width and height.</p>

    <h4>Returns</h4>

    <p>A single image representing the average of all the images in
    the imagelist.</p>

    <h4>Example</h4>

    <p class="rollover"><a href=
    "javascript:popup('average.rb.html')">
    <!-- This img tag displays the original image when the mouse is over -->
     <img style="display:none" id="notaveraged" onmouseout=
    "this.style.display='none'; averaged.style.display=''; averagedspin.style.display='';"
    title="Click to see the example script" src=
    "ex/average_before.gif" alt="average example" /><!--
                                  This img tag displays the averaged image when the mouse is not over
                                  --><img style="display:" id=
"averaged" onmouseover=
"this.style.display='none'; notaveraged.style.display=''; averagedspin.style.display='none';"
    src="ex/average_after.gif" alt="average example" /></a>
    <img src="ex/images/spin.gif" alt="" class="spin" style=
    "left:131px; display:" id="averagedspin" title=
    "Mouse over the example to see the 3 original images" /></p>

    <h4>Magick API</h4>

    <p>AverageImages</p>
  </div>

  <div class="sig">
    <h3 id="clone">clone</h3>

    <p><span class="arg">imagelist</span>.clone -&gt;
    <em>anImageList</em></p>
  </div>

  <div class="desc">
    <h4>Description</h4>

    <p>Same as <a href="#dup">dup</a>, but the frozen state of the
    original is propogated to the copy.</p>

    <h4>Returns</h4>

    <p>A new imagelist</p>

    <h4>See also</h4>

    <p><a href="#copy">copy</a></p>
  </div>

  <div class="sig">
    <h3 id="coalesce">coalesce</h3>

    <p><span class="arg">imagelist.</span>coalesce -&gt;
    <em>anImageList</em></p>
  </div>

  <div class="desc">
    <h4>Description</h4>

    <p>Merges all the images in the imagelist into a new imagelist.
    Each image in the new imagelist is formed by flattening all the
    previous images.</p>

    <p>The length of time between images in the new image is
    specified by the <a href=
    "imageattrs.html#Image.delay">delay</a> attribute of the input
    image. The position of the image on the merged images is
    specified by the <a href="imageattrs.html#Image.page">page</a>
    attribute of the input image.</p>

    <h4>Returns</h4>

    <p>A new imagelist</p>

    <h4>Example</h4>

    <p>This example is an animated GIF created by coalescing 25
    small images in a grid. Mouse over the image to start the
    animation.</p>

    <p class="rollover"><a href=
    "javascript:popup('coalesce.rb.html')"><img onmouseover=
    "this.src='ex/coalesce_anim.gif'" onmouseout=
    "this.src='ex/coalesce.gif'" src="ex/coalesce.gif" alt=
    "coalesce example" title=
    "Click the image to see the example script" /></a><img src=
    "ex/images/spin.gif" alt="" class="spin" style="left:159px"
    title="Mouse over the example to see the animation" /></p>

    <h4>See also</h4><a href="#flatten_images">flatten_images</a>

    <h4>Magick API</h4>

    <p>CoalesceImages</p>
  </div>

  <div class="sig">
    <h3 id="copy">copy</h3>

    <p><span class="arg">imagelist.</span>copy -&gt;
    <em>anImageList</em></p>
  </div>

  <div class="desc">
    <h4>Description</h4>

    <p>Creates a deep copy of the imagelist. The new imagelist
    contains a copy of all the images in the original
    imagelist.</p>

    <h4>Returns</h4>

    <p>An imagelist</p>

    <h4>Example</h4>
    <pre>
imagelist2 = imagelist1.copy
</pre>

    <h4>See also</h4><a href="image1.html#copy">Image#copy</a>,
    <a href="#clone">clone</a>, <a href="#dup">dup</a>
  </div>

  <div class="sig">
    <h3 id="cur_image">cur_image</h3>

    <p><span class="arg">imagelist.</span>cur_image -&gt;
    <em>anImage</em></p>
  </div>

  <div class="desc">
    <h4>Description</h4>

    <p>Retrieves the image indexed by <a href="#scene">scene</a>.
    Raises <code>IndexError</code> if there are no images in the
    list.</p>

    <p>Both the ImageList class and the Image class support the
    <code>cur_image</code> method. Of course, in the Image class,
    <code>cur_image</code> simply returns <code>self</code>. When a
    method accepts either an image or a imagelist as an argument,
    it sends the <code>cur_image</code> method to the argument to
    get the current image.</p>

    <h4>Returns</h4>

    <p>An image</p>
  </div>

  <div class="sig">
    <h3 id="deconstruct">deconstruct</h3>

    <p><span class="arg">imagelist.</span>deconstruct -&gt;
    <em>anImageList</em></p>
  </div>

  <div class="desc">
    <h4>Description</h4>

    <p>This method constructs a new imagelist containing images
    that include only the changed pixels between each image and its
    successor. The resulting imagelist usually produces a much
    smaller file.</p>

    <p>The <code>desconstruct</code> method starts by copying the
    first image in the list to the output imagelist. Then, for each
    pair of images, <code>deconstruct</code> computes the smallest
    rectangle that encompasses all the changes between the first
    and second image and stores just the changed rectangle of the
    second image, along with the offset of the rectangle relative
    to the boundary of the first image.</p>

    <h4>Returns</h4>

    <p>A new imagelist</p>

    <h4>Magick API</h4>

    <p>DeconstructImages</p>
  </div>

  <div class="sig">
    <h3 id="dup">dup</h3>

    <p><span class="arg">imagelist</span>.dup -&gt;
    <em>anImageList</em></p>
  </div>

  <div class="desc">
    <h4>Description</h4>

    <p>Makes a <em>shallow</em> copy of the receiver. The image
    elements in the new imagelist are references to the image
    elements in the original imagelist, not copies.</p>

    <h4>See also</h4>

    <p><a href="#copy">copy</a>, <a href="#clone">clone</a></p>
  </div>

  <div class="sig">
    <h3 id="display">display</h3>

    <p><span class="arg">imagelist.</span>display <span class=
    "arg">[&nbsp;{ optional arguments }&nbsp;]</span> -&gt;
    <em>self</em></p>
  </div>

  <div class="desc">
    <h4>Description</h4>

    <p>Displays the images in the imagelist to any X Window screen.
    By default displays to the local screen. You can specify a
    different screen by assigning the name to the
    <code>server_name</code> attribute in the optional arguments
    block.</p>

    <h4>Returns</h4>

    <p>self</p>

    <h4>See also</h4>

    <p><a href="#animate">animate</a>, <a href=
    "image1.html#display">Image#display</a></p>

    <h4>Magick API</h4>

    <p>DisplayImages</p>
  </div>

  <div class="sig">
    <h3 id="flatten_images">flatten_images</h3>

    <p><span class="arg">imagelist.</span>flatten_images -&gt;
    <em>anImage</em></p>
  </div>

  <div class="desc">
    <h4>Description</h4>

    <p>Combines all the images in the imagelist into a single image
    by overlaying each successive image onto the preceding images.
    If a image has transparent areas, the underlying image will
    show through. Use the <a href="imageattrs.html#page">page</a>
    attribute to specify the position of each image with respect to
    the preceding images.</p>

    <p class="imquote">This is useful for combining Photoshop
    layers into a single image.</p>

    <h4>Returns</h4>

    <p>An image</p>

    <h4>Example</h4>

    <p><a href=
    "javascript:popup('flatten_images.rb.html')"><img alt=
    "flatten_images example" src="ex/flatten_images.gif" title=
    "Click to see the example script" /></a></p>

    <h4>See also</h4>

    <p><a href="#coalesce">coalesce</a></p>

    <h4>Magick API</h4>

    <p>FlattenImageList</p>
  </div>

  <div class="sig">
    <h3 id="from_blob">from_blob</h3>

    <p><span class=
    "arg">imagelist.</span>from_blob(blob<span class="arg">[,
    blob...]</span>) <span class="arg">[&nbsp;{ optional arguments
    }&nbsp;]</span> -&gt; <em>self</em></p>
  </div>

  <div class="desc">
    <h4>Description</h4>

    <p>Creates images from the blob (<em>B</em>inary <em>L</em>arge
    <em>O</em>bjects) arguments and appends the images to the
    imagelist.</p>

    <h4>Arguments</h4>

    <p>A <em>blob</em> can be a string containing an image file
    such as a JPEG or GIF. The string can contain a multi-image
    file such as an animated GIF or a Photoshop image with multiple
    layers. A blob can also be one of the strings produced by
    <a href="#to_blob">to_blob</a>. Control how the image(s) are
    created by setting additional <a href=
    "info.html">Image::Info</a> attributes in the optional block
    argument. Useful attributes include <a href=
    "info.html#scene">scene</a>, <a href=
    "info.html#number_scenes">number_scenes</a>, and <a href=
    "info.html#extract">extract</a>.</p>

    <h4>Returns</h4>

    <p>An image created from the blob argument(s). The
    <code>scene</code> attribute is set to the last image in the
    imagelist.</p>

    <h4>Example</h4>
    <pre>
require 'RMagick'

f = File.open('Cheetah.jpg')
blob = f.read

ilist = Magick::ImageList.new
ilist.from_blob(blob)
ilist.display
</pre>

    <h4>See also</h4><a href="#to_blob">to_blob</a>, <a href=
    "image3.html#to_blob">Image#to_blob</a>, <a href=
    "image1.html#from_blob">Image.from_blob</a>

    <h4>Magick API</h4>

    <p>BlobToImageList</p>
  </div>

  <div class="sig">
    <h3 id="inspect">inspect</h3>

    <p><span class="arg">imagelist.</span>inspect -&gt;
    <em>aString</em></p>
  </div>

  <div class="desc">
    <h4>Description</h4>

    <p>Produces a string that describes the images in the
    imagelist.</p>

    <h4>Arguments</h4>

    <h4>Returns</h4>

    <p>The returned string is a concatenation of the strings
    returned by <a href="image2.html#inspect">Image#inspect</a> for
    all the images in the imagelist.</p>

    <h4>Example</h4>
    <pre>
i = Magick::ImageList.new("images/Button_A.gif", "images/Button_B.gif")
&raquo; [images/Button_A.gif GIF 127x120+0+0 PseudoClass 256c 8-bit 18136b
images/Button_B.gif GIF 127x120+0+0 PseudoClass 256c 8-bit 5157b]
scene=1
</pre>

    <h4>See also</h4>

    <p><a href="image2.html#inspect">Image#inspect</a></p>

    <h4>Magick API</h4>

    <p>The description is essentially the same as that provided by
    <a href=
    "http://www.imagemagick.org/www/api/image.html#describeimage">DescribeImageList</a></p>
  </div>

  <div class="sig">
    <h3 id="map">map</h3>

    <p><span class="arg">imagelist.map</span>(<span class=
    "arg">reference</span>, <span class="arg">dither</span>) -&gt;
    <em>anImageList</em></p>
  </div>

  <div class="desc">
    <h4>Description</h4>

    <p>Reduces the colors in the imagelist images to the set of
    colors in the <span class="arg">reference</span> image.</p>

    <h4>Arguments</h4>

    <dl>
      <dt>reference</dt>

      <dd>An image or a imagelist. If an imagelist,
      <code>map</code> uses the current image as the reference
      image.</dd>

      <dt>dither</dt>

      <dd>if <code>true</code>, dither the mapped images.</dd>
    </dl>

    <h4>Returns</h4>

    <p>A new imagelist the same length as the receiver.</p>

    <h4>Example</h4>

    <p>This example demonstrates how to map images into the 216
    "Web safe" colors. Mouse over the image to see the images
    before mapping.</p>

    <p class="rollover"><a href=
    "javascript:popup('map.rb.html')"><img src="ex/map_after.jpg"
    alt="map example" title="Click to see the example script"
    onmouseover="this.src='ex/map_before.jpg'" onmouseout=
    "this.src='ex/map_after.jpg'" /></a><img src=
    "ex/images/spin.gif" alt="" class="spin" style="left: 525px;"
    title="Mouse over the example to see the original image" /></p>

    <h4>See also</h4>

    <p><a href="image2.html#map">Image#map</a>, <a href=
    "#quantize">quantize</a></p>

    <h4>Magick API</h4>

    <p>MapImages</p>
  </div>

  <div class="sig">
    <h3 id="montage">montage</h3>

    <p><span class="arg">imagelist.</span>montage <span class=
    "arg">[&nbsp;{ optional arguments }&nbsp;]</span> -&gt;
    <em>anImageList</em></p>
  </div>

  <div class="desc">
    <h4>Description</h4>

    <p>Creates a composite image by reducing the size of the input
    images and arranging them in a grid on the background color or
    texture of your choice. There are many configuration options.
    For example, you can specify the number of columns and rows,
    the distance between images, and include a label with each
    small image (called a <em>tile</em>).</p>

    <p>All of <code>montage</code>'s configuration options are
    specified by assigning values to attributes in a block
    associated with the method call.</p>

    <p>As you can see in the examples below, when you assign a
    value to a montage attribute you must specify <code>self</code>
    as the receiver so that Ruby can distinguish the method call
    from an assignment to a local variable.</p>

    <p>You may assign a <a href="struct.html#Pixel">Pixel</a>
    object to any attribute that accepts a color name.</p>

    <h4>Montage attributes</h4>

    <dl>
      <dt>background_color=</dt>

      <dd>The composite image background color.</dd>

      <dt>border_color=</dt>

      <dd>The tile border color.</dd>

      <dt>border_width=</dt>

      <dd>The tile border width in pixels.</dd>

      <dt>compose=</dt>

      <dd>The <a href="constants.html#CompositeOperator">composite
      operator</a> to use when compositing the tile images onto the
      background. The default composition operator is
      <code>OverCompositeOp</code>.</dd>

      <dd><em>Hint:</em> You can use a different composite operator
      for each tile by setting each image's <a href=
      "imageattrs.html#Image.compose">compose=</a> attribute to the
      desired operator. In the optional arguments block, set
      <code>compose</code> to UndefinedCompositeOp.</dd>

      <dt>fill=</dt>

      <dd>If the tiles have labels, the label fill color. The
      default fill color is black.</dd>

      <dt>font=</dt>

      <dd>If the tiles have labels, the label font. The default
      font is Helvetica.</dd>

      <dt>frame=</dt>

      <dd>
        The size of an ornamental frame surrounding each tile. The
        frame specification may be either a string or a <a href=
        "struct.html#Geometry">Geometry</a> object. If the argument
        is a string, it must have the form
        <code>&lt;width&gt;x&lt;height&gt;+&lt;outer bevel
        width&gt;+&lt;inner bevel width&gt;</code>. If the argument
        is a Geometry object, specify the width and height of the
        frame with the <code>width</code> and <code>height</code>
        attributes, and specify the outer bevel width and the inner
        bevel width with the <code>x</code> and <code>y</code>
        attributes. The values are in pixels. For example, to
        surround each tile with a frame 20 pixels wide by 20 pixels
        high and a 4-pixel inner and outer bevel, use:
        <pre>
self.frame = "20x20+4+4"
</pre>or
        <pre>
self.frame = Magick::Geometry.new(20,20,4,4)
</pre>
      </dd>

      <dd>If the tile has a label, the label is included in the
      frame. The default is to have no frame.</dd>

      <dd>See <a href="image1.html#frame">Image#frame</a>.</dd>

      <dt>geometry=</dt>

      <dd>
        The size of the tiles and the distance between tiles. The
        value can be either a <a href=
        "imusage.html#geometry">geometry string</a> or a <a href=
        "struct.html#Geometry">Geometry</a> object. The geometry
        string has the form:
        <code>&lt;tile-width&gt;x&lt;tile-height&gt;+&lt;distance-between-columns&gt;+&lt;distance-between-rows&gt;</code>.
        If you use a Geometry object, specify the tile width and
        height with the <code>width</code> and <code>height</code>
        attributes, and the distance between rows and distance
        between columns by the <code>x</code> and <code>y</code>
        attributes. To create tiles that are 130 pixels wide and
        194 pixels tall, with 10 pixels between each column of
        tiles and 5 between each row, use:
        <pre>
self.geometry = "130x194+10+5"
</pre>or
        <pre>
self.geometry = Magick::Geometry.new(130, 194, 10, 5)
</pre>Both the geometry string and the <code>Geometry</code> object
support flags that specify additional constraints. The default
geometry is "120x120+4+3&gt;".
      </dd>

      <dt>gravity=</dt>

      <dd>The <a href="constants.html#GravityType">direction</a>
      used when adding the tile labels. (See <a href=
      "draw.html#Draw.annotate">annotate</a>.)</dd>

      <dt>matte_color=</dt>

      <dd>The matte color. The default is #bdbdbd.</dd>

      <dt>pointsize=</dt>

      <dd>If the tiles have labels, the size of the label font in
      points. The default is 12 points.</dd>

      <dt>shadow=</dt>

      <dd>If set to <code>true</code>, adds a drop shadow to each
      tile. The default is <code>false</code>.</dd>

      <dt>stroke=</dt>

      <dd>If the tiles have labels, sets the stroke (outline) color
      of the label text. The default is "transparent".</dd>

      <dt>texture=</dt>

      <dd>
        A image to be tiled on the background of the composite
        image. If present, this attribute overrides the background
        color. For example, to use &times;Magick's built-in
        "granite" texture as the background, use:
        <pre>
self.texture = Magick::Image.read("granite:").first
</pre>

        <p>The default is no texture.</p>
      </dd>

      <dt>tile=</dt>

      <dd>
        The number of columns and rows to use when arranging the
        tiles on the composite image. The value can be either a
        string or a <a href="struct.html#Geometry">Geometry</a>
        object. If the value is a string, it should have the form
        <code>"&lt;columns&gt;x&lt;rows&gt;"</code>. If the value
        is a Geometry object, specify the number of columns as the
        <code>width</code> attribute and the number of rows as the
        <code>height</code> attribute. <code>montage</code> always
        generates all the rows, leaving empty cells if necessary.
        To arrange the tiles 4 across and 10 down, use:
        <pre>
self.tile = "4x10"
</pre>or
        <pre>
self.tile = Magick::Geometry.new(4,10)
</pre>

        <p>The default is "6x4". If there are too many tiles to fit
        on one composite image, <code>montage</code> creates
        multiple composite images.</p>
      </dd>
    </dl>

    <h4>Tile labels</h4>

    <p>To add labels to the tiles, assign a "Label" property to
    each image. The <code>montage</code> method will use the value
    of the property as the label. For example,</p>
    <pre>
img[2]['Label'] = "Mom's Birthday"
</pre>

    <p>See <a href="image1.html#aset">[]=</a>.</p>

    <h4>Returns</h4>

    <p>An imagelist that contains as many images as are required to
    display all the tiles.</p>

    <h4>Example</h4><a href=
    "javascript:popup('demo.rb.html')">demo.rb</a>

    <h4>Magick API</h4>

    <p>MontageImages</p>
  </div>

  <div class="sig">
    <h3 id="morph">morph</h3>

    <p><span class="arg">imagelist.</span>morph(<span class=
    "arg">n</span>) -&gt; <em>anImageList</em></p>
  </div>

  <div class="desc">
    <h4>Description</h4>

    <p>Transforms a image into another image by inserting
    <code>n</code> in-between images. Requires at least two images.
    If more images are present, the 2nd image is transformed into
    the 3rd, the 3rd to the 4th, etc.</p>

    <h4>Arguments</h4>

    <p>The number of in-between images to insert between each pair
    of images.</p>

    <h4>Returns</h4>

    <p>An imagelist containing copies of the original images plus
    the in-between images.</p>

    <h4>Example</h4>

    <p>This animated GIF was created by reading the "0", "1", "2"
    and "3" images, then using <code>morph</code> to create 8
    images between each original image. Mouse over the image to
    start the animation.</p>

    <p class="rollover"><a href=
    "javascript:popup('morph.rb.html')"><img onmouseover=
    "this.src='ex/morph.gif'" onmouseout=
    "this.src='ex/images/Button_0.gif'" src=
    "ex/images/Button_0.gif" alt="morph example" title=
    "Click the image to see the example script" /></a><img src=
    "ex/images/spin.gif" alt="" class="spin" style="left:131px"
    title="Mouse over the example to see the animation" /></p>

    <h4>Magick API</h4>

    <p>MorphImages</p>
  </div>

  <div class="sig">
    <h3 id="mosaic">mosaic</h3>

    <p><span class="arg">imagelist.</span>mosaic -&gt;
    <em>anImage</em></p>
  </div>

  <div class="desc">
    <h4>Description</h4>

    <p>Composites all the images into a single new image. The
    location of each image is determined by the value of its
    <a href="imageattrs.html#Image.page">page</a> attribute.</p>

    <h4>Returns</h4>

    <p>An image</p>

    <h4>Example</h4>

    <p><a href="javascript:popup('mosaic.rb.html')"><img src=
    "ex/mosaic.gif" alt="mosaic example" title=
    "Click to see the example script" /></a></p>

    <h4>See also</h4><a href="#coalesce">coalesce</a>, <a href=
    "#flatten_images">flatten_images</a>, <a href=
    "#montage">montage</a>

    <h4>Magick API</h4>

    <p>MosaicImages</p>
  </div>

  <div class="sig">
    <h3 id="new_image">new_image</h3>

    <p><span class="arg">imagelist.</span>new_image(<span class=
    "arg">columns</span>, <span class="arg">rows</span><span class=
    "arg">[, fill]</span>) <span class="arg">[&nbsp;{ optional
    arguments }&nbsp;]</span> -&gt; <em>self</em></p>
  </div>

  <div class="desc">
    <h4>Description</h4>

    <p>Adds a new image to the imagelist. The image can have an
    optional <a href="struct.html#fill">fill</a> applied to it.</p>

    <h4>Arguments</h4>

    <p>Creates a new image with the specified number of rows and
    columns. If the optional <code>fill</code> argument is used,
    calls the <code>fill</code> method to fill the image.
    Otherwise, the image is filled with the background color.</p>

    <p>You can set any <a href="info.html">Image::Info</a>
    attributes in an associated block. These attributes supply
    options to be used when creating the image. For example, you
    can specify the <a href=
    "imageattrs.html#background_color">background color</a> to fill
    the image with (see the example), the <a href=
    "imageattrs.html#depth">depth</a>, <a href=
    "imageattrs.html#border_color">border color</a>, etc.</p>

    <h4>Returns</h4>

    <p>self</p>

    <h4>Example</h4>

    <p>Create a square red image.</p>
    <pre>
imagelist = Magick::ImageList.new
imagelist.new_image(100, 100) { self.background_color = "red" }
</pre>
  </div>

  <div class="sig">
    <h3 id="ping">ping</h3>

    <p><span class="arg">imagelist.</span>ping(<span class=
    "arg">filename</span>[, <span class="arg">filename</span>...])
    -&gt; <em>self</em><br />
    <span class="arg">imagelist.</span>ping(<span class=
    "arg">file</span>[, <span class="arg">file</span>...]) -&gt;
    <em>self</em></p>
  </div>

  <div class="desc">
    <h4>Description</h4>

    <p>Reads the image files and creates one or more images that
    contain all the image attributes but without the pixel data. If
    all you need is the image attributes, the <code>ping</code>
    method is much faster and consumes less memory than <a href=
    "#read"><code>read</code></a>.</p>

    <h4>Arguments</h4>

    <p>One or more image file names or open file objects.</p>

    <h4>Returns</h4>

    <p>self</p>

    <h4>Example</h4>
    <pre>
imagelist = Magick::ImageList.new
imagelist.ping "Button_A.gif"
puts "The image has #{i.columns} columns and #{i.rows} rows." &raquo;
      The image has 127 columns and 120 rows.
</pre>

    <h4>See also</h4><a href="#read">read</a>

    <h4>Magick API</h4>

    <p>PingImage</p>
  </div>

  <div class="sig">
    <h3 id="quantize">quantize</h3>

    <p><span class="arg">imagelist.</span>quantize(nc=256,
    colorspace=<code>Magick::RGBColorspace</code>,
    dither=<code>true</code>, tree_depth=0,
    measure_error=<code>false</code>) -&gt;
    <em>anImageList</em></p>
  </div>

  <div class="desc">
    <h4>Description</h4>

    <p class="imquote">Analyzes the colors within a set of
    reference images and chooses a fixed number of colors to
    represent the set. The goal of the algorithm is to minimize the
    difference between the input and output images while minimizing
    the processing time.</p>

    <h4>Arguments</h4>

    <dl>
      <dt>nc</dt>

      <dd>The maximum number of colors to use in the output images.
      Must be less than or equal to <a href=
      "constants.html#Miscellaneous_constants">MaxRGB</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 class="imquote">Apply Floyd/Steinberg error diffusion to
      the image. When the size of the color palette is less than
      the image colors, this trades off spacial resolution for
      color resolution by dithering to achieve a similar looking
      image.</dd>

      <dt>tree_depth</dt>

      <dd class="imquote">Specify 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 two to eight. The ideal tree depth depends on
      the characteristics of the input image, and may be determined
      through experimentation.</dd>

      <dt>measure_error</dt>

      <dd><span class="imquote">Calculate quantization errors when
      quantizing the image.</span> Stores the results for each
      image in the imagelist <a href=
      "imageattrs.html#Image.mean_error_per_pixel">mean_error_per_pixel</a>,
      <a href=
      "imageattrs.html#Image.normalized_maximum_error">normalized_maximum_error</a>,
      and <a href=
      "imageattrs.html#Image.normalized_mean_error">normalized_mean_error</a>
      attributes. Stores the number of colors used for the image in
      the <a href=
      "imageattrs.html#Image.total_colors">total_colors</a>
      attribute.</dd>
    </dl>

    <h4>Returns</h4>

    <p>A new imagelist containing quantized copies of the images in
    the original image.</p>

    <h4>Example</h4>

    <p>This example shows the effect of quantizing 3 images to a
    set of 16 colors in the RGB colorspace. Mouse over the image to
    see the images before quantizing.</p>

    <p class="rollover"><a href=
    "javascript:popup('quantize-m.rb.html')"><img src=
    "ex/quantize-m_after.jpg" alt="quantize example" title=
    "Click to see the example script" onmouseover=
    "this.src='ex/quantize-m_before.jpg'" onmouseout=
    "this.src='ex/quantize-m_after.jpg'" /></a> <img src=
    "ex/images/spin.gif" alt="" class="spin" style="left: 505px;"
    title="Mouse over the example to see the original image" /></p>

    <h4>See also</h4>

    <p><a href="image3.html#quantize">Image#quantize</a></p>

    <h4>Magick API</h4>

    <p>QuantizeImages</p>
  </div>

  <div class="sig">
    <h3 id="read">read</h3>

    <p><span class="arg">imagelist.</span>read(<span class=
    "arg">filename[, filename...]</span>) <span class=
    "arg">[&nbsp;{ optional arguments }&nbsp;]</span> -&gt;
    <em>self</em><br />
    <span class="arg">imagelist.</span>read(<span class=
    "arg">file[, file...]</span>) <span class="arg">[&nbsp;{
    optional arguments }&nbsp;]</span> -&gt; <em>self</em></p>
  </div>

  <div class="desc">
    <h4>Description</h4>

    <p>Reads one or more image files and adds the images to the
    imagelist. After reading all the files, sets the <a href=
    "#scene">scene</a> number to the last image in the list.</p>

    <p>The image files may be multi-frame (animated or layered)
    files. In this case <code>read</code> adds multiple images per
    file to the imagelist.</p>

    <h4>Arguments</h4>

    <p>One or more filenames or open file objects. You can also
    specify optional arguments to be used when reading the file(s)
    by setting <a href="info.html">Image::Info</a> attributes in
    the optional block.</p>

    <h4>Returns</h4>

    <p>self</p>

    <h4>Example</h4>
    <pre>
i = Magick::ImageList.new
number = '0'
4.times do
        i.read "images/Button_" + number + ".gif"
        number.succ!
        end
</pre>

    <p>Also see the <a href="#morph">morph</a> example and <a href=
    "javascript:popup('demo.rb.html')">demo.rb</a>.</p>

    <h4>See also</h4>

    <p><a href="image3.html#read">Image.read</a></p>

    <h4>Magick API</h4>

    <p>ReadImage</p>

    <h4>Notes</h4>

    <p>You can create images using &times;Magick's built-in formats
    with the <code>read</code> method. See <a href=
    "imusage.html#builtin_formats">Built-in image formats</a>.</p>
  </div>

  <div class="sig">
    <h3 id="to_blob">to_blob</h3>

    <p><span class="arg">imagelist.</span>to_blob <span class=
    "arg">[&nbsp;{ optional arguments }&nbsp;]</span> -&gt;
    <em>aString</em></p>
  </div>

  <div class="desc">
    <h4>Description</h4>

    <p>Converts the images in the imagelist to a <em>blob</em>.
    <span class="imquote">A blob contains data that directly
    represent a particular image format in memory instead of on
    disk.</span></p>

    <p>Control the format of the blob by setting <a href=
    "info.html">Image::Info</a> attributes in an associated
    block.</p>

    <h4>Returns</h4>

    <p>The blob in the form of a string</p>

    <h4>Example</h4>
    <pre>
i = Magick::ImageList.new "birthday.png"
s = i.to_blob &raquo; a string representing the image.
</pre>

    <h4>See also</h4>

    <p><a href="#from_blob">from_blob</a>, <a href=
    "image3.html#to_blob">Image#to_blob</a>, <a href=
    "image1.html#from_blob">Image.from_blob</a></p>

    <h4>Magick API</h4>

    <p>ImageListToBlob</p>
  </div>

  <div class="sig">
    <h3 id="write">write</h3>

    <p><span class="arg">imagelist.</span>write(<span class=
    "arg">filename</span>) <span class="arg">[&nbsp;{ optional
    arguments }&nbsp;]</span> -&gt; <em>self</em><br />
    <span class="arg">imagelist.</span>write(<span class=
    "arg">file</span>) <span class="arg">[&nbsp;{ optional
    arguments }&nbsp;]</span> -&gt; <em>self</em></p>
  </div>

  <div class="desc">
    <h4>Description</h4>

    <p>If the image format <a href="imusage.html#formats">indicated
    by the filename</a> supports multiple images per file (animated
    images), <code>write</code> writes all the images in the
    imagelist to a single file. Otherwise, <code>write</code>
    writes each image to a separate file.</p>

    <p>Regardless of the original format, <code>write</code>
    converts the images to the format specified by the
    filename.</p>

    <p>If the imagelist contains more than one image and the output
    format does not support multi-frame images, each image is
    written to a file that has the filename you specify followed by
    a period (.) and the scene number. You can change this behavior
    by embedding a %d, %0Nd, %o, %0No, %x, or %0Nx printf format
    specification in the file name.</p>

    <h4>Arguments</h4>

    <p>A filename or open file object. Indicate the desired image
    <a href="imusage.html#formats">format</a> either by the suffix
    (i.e. <code>.jpg</code>, <code>.png</code>) or the prefix
    (<code>ps:</code>) to the filename. If the argument is an open
    file object, you can specify a format for each image in the
    list by setting its <a href="imageattrs.html#format">format</a>
    attribute.</p>

    <p>You can also specify optional arguments by setting <a href=
    "info.html">Image::Info</a> attributes in an associated
    block.</p>

    <h4>Returns</h4>

    <p>self, or <code>nil</code> if the format cannot be
    determined.</p>

    <h4>Example</h4>
    <pre>
# The PNG format does not support multi-frame files,
# so each image is written to a separate file.
i = Magick::ImageList.new "animated.gif"
p i.length &raquo; 3 # contains 3 images
i.write "test.png" &raquo; test.png.0
                   &raquo; test.png.1
                   &raquo; test.png.2
# &times;Magick's MIFF format does support multi-frame
# files, so all 3 images are written to one file.
i.write "animated.miff" &raquo; animated.miff
</pre>

    <h4>See also</h4>

    <p><a href="image3.html#write">Image#write</a></p>

    <h4>Magick API</h4>

    <p>WriteImages</p>
  </div>

  <p class="spacer">&nbsp;</p>

  <div class="nav">
    &laquo;&nbsp;<a href="magick.html">Prev</a> | <a href=
    "index.html">Contents</a> | <a href=
    "imageattrs.html">Next</a>&nbsp;&raquo;
  </div>
</body>
</html>