RMagick 2.13.1: class ImageList

###### RMagick 2.13.1 User's Guide and Reference

# class ImageList
mixes in Comparable, Enumerable

## class methods

### new

Magick::ImageList.new [ { optional arguments } ] -> imagelist
Magick::ImageList.new(filename[, filename...]]) [ { optional arguments } ] -> imagelist

#### Description

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 `nil` if no filenames are specified.

#### Arguments

Zero or more image file names. You can also specify optional arguments to be used when reading the file(s) by setting Image::Info attributes in the optional block.

#### Returns

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.

#### Example

    i = Magick::ImageList.new
    i = Magick::ImageList.new("Button_A.gif", "Cheetah.jpg")

## attributes

### delay=

ilist.delay=n

#### Description

In conjunction with ticks_per_second sets the length of time between each image in an animation. The `delay=` attribute assigns the same delay to all the images in the ilist. Use Image#delay= to set different delay values on individual images.

#### Arguments

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

#### Returns

self

#### Example

    ilist.delay = 20 # delay 1/5 of a second between images.

#### See also

Image#delay=

### iterations=

ilist.iterations=n

#### Description

Sets the number of times an animated image should loop.

The animate method and the ImageMagick animate command does not respect this number. Both will repeat the animation until you stop them. Mozilla (and presumably Netscape) do respect the value..

#### Arguments

The number of iterations.

#### Returns

self

#### Example

    ilist.iterations = 10

### length

ilist.length -> integer

#### Description

Returns the number of images in the imagelist.

#### Example

    i = Magick::ImageList.new("images/Button_A.gif", "images/Button_B.gif")
    i.length » 2

### scene, scene=

ilist.scene -> integer
ilist.scene = integer

#### Description

Get/set the current scene number. The scene number indicates the image to which Image methods are sent.

#### Example

    ilist.scene = 10
    ilist.scene » 10

### ticks_per_second=

ilist.ticks_per_second = integer

#### Description

Used in conjunction with delay to establish the elapsed time between frames in an animation. By default the number of ticks per second is 100.

#### Example

    ilist.ticks_per_second = 1000

## instance methods

### Array methods

#### Description

`ImageList` delegates many methods to `Array`, so you can manipulate the images in an imagelist using almost all of the methods defined in `Array`. 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 `nil`.

Array methods that would normally return an array return an ImageList.

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.

Array method behavior
Array method | scene number will be...
--- | ---
<< | set to index the last image in the list
clear | set to `nil`
concat | set to index the last image in the list
push | set to index the last image in the list
unshift | set to 0

Adding anything other than a image to an imagelist has undefined results. Most of the time RMagick will raise an ArgumentError exception. For example, if you call `collect!` on an imagelist you should make sure that the members of the imagelist remain images. If you need to replace images in an imagelist with non-image objects, convert the imagelist to an array with the `to_a` method, then modify the array.

The `assoc`, `flatten`, `flatten!`, `join`, `pack`, and `rassoc` methods are not defined in the ImageList class.

#### Example

Add noise to a model image. Append the resulting image to the imagelist in "example". (See the `demo.rb` example.)

    example = Magick::ImageList.new
    model = Magick::ImageList.new "model.miff"
    example << model.add_noise Magick::LaplacisanNoise

#### See also

scene, scene=

### <=>

ilist <=> other_imagelist -> -1, 0, 1

#### Description

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:

1. For all images `n`, if the result of `a[n] <=> b[n]` is not 0 then that is the result of a <=> b. Individual images are compared by comparing their signatures.
2. If `a.scene <=> b.scene` is not 0, returns the result
3. Returns `a.length <=> b.length`

`ImageList` mixes in the `Comparable` module.

#### See also

Image#<=>, signature

### animate

ilist.animate([delay]) [ { optional arguments } ] -> self

#### Description

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 `server_name` attribute in the optional arguments block.

#### Returns

self

#### Example

    ilist.animate
    ilist.animate { self.server_name = "other:0.0" }

#### See also

display

#### Note

The animate method is not supported on native MS Windows.

#### Magick API

AnimateImages

### append

ilist.append(`true` or `false`) -> image

#### Description

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.

#### Arguments

If `true`, rectangular images are stacked top-to-bottom, otherwise left-to-right.

#### Returns

A image composed of all the images in the imagelist.

#### Magick API

AppendImages

### average

ilist.average -> image

#### Description

Averages all the images together. Each image in the image must have the same width and height.

#### Returns

A single image representing the average of all the images in the imagelist.

#### Example

#### Magick API

AverageImages

### clone

ilist.clone -> other_imagelist

#### Description

Same as dup, but the frozen state of the original is propagated to the copy.

#### Returns

A new imagelist

#### See also

copy

### coalesce

ilist.coalesce -> imagelist

#### Description

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.

The length of time between images in the new image is specified by the delay attribute of the input image. The position of the image on the merged images is specified by the page attribute of the input image.

#### Returns

A new imagelist

#### Example

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

#### See also

flatten_images, optimize_layers

#### Magick API

CoalesceImages

### composite_layers

destination_list.composite_layers(source_list, operator=`OverCompositeOp`) -> imagelist

#### Description

An image from source_list is composited over an image from destination_list until one list is finished. Use the geometry and gravity attributes of the first image in destination_list to position the source images over the destination images. Unlike a normal composite operation, the canvas offset is also included to the composite positioning. If one of the image lists only contains one image, that image is applied to all the images in the other image list, regardless of which list it is. In this case it is the image meta-data of the list which preserved.

#### Arguments

The optional operator argument specifies a CompositeOperator to use for the compositing operations.

#### Returns

An imagelist

#### Example

This example is an animated GIF. Mouse over the image to start the animation.

#### Notes

This method is equivalent to the `-layers Composite` option of ImageMagick's `convert` command. See the Layers Composition section in Examples of ImageMagick Usage for more information.

#### See also

optimize_layers

### copy

ilist.copy -> other_imagelist

#### Description

Creates a deep copy of the imagelist. The new imagelist contains a copy of all the images in the original imagelist.

#### Returns

An imagelist

#### Example

    imagelist2 = imagelist1.copy

#### See also

Image#copy, clone, dup

### cur_image

ilist.cur_image -> image

#### Description

Retrieves the image indexed by scene. Raises `IndexError` if there are no images in the list.

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

#### Returns

An image

### deconstruct

ilist.deconstruct -> imagelist

#### Description

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.

The `deconstruct` method starts by copying the first image in the list to the output imagelist. Then, for each pair of images, `deconstruct` 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.

#### Returns

A new imagelist

#### Magick API

DeconstructImages

#### See also

optimize_layers

### dup

ilist.dup -> other_imagelist

#### Description

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

#### See also

copy, clone

### display

ilist.display [ { optional arguments } ] -> self

#### Description

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 `server_name` attribute in the optional arguments block.

#### Returns

self

#### See also

animate, Image#display

#### Note

The display method is not supported on native MS Windows.

#### Magick API

DisplayImages

### flatten_images

ilist.flatten_images -> image

#### Description

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 page attribute to specify the position of each image with respect to the preceding images.

This is useful for combining Photoshop layers into a single image.

#### Returns

An image

#### Example

#### See also

coalesce, optimize_layers

#### Magick API

MergeImageLayers with the FlattenLayer method.

### from_blob

ilist.from_blob(blob[, blob...]) [ { optional arguments } ] -> self

#### Description

Creates images from the blob (Binary Large Objects) arguments and appends the images to the imagelist.

#### Arguments

A blob 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 to_blob. Control how the image(s) are created by setting additional Image::Info attributes in the optional block argument. Useful attributes include scene, number_scenes, and extract.

#### Returns

An image created from the blob argument(s). The `scene` attribute is set to the last image in the imagelist.

#### Example

    require 'RMagick'

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

    ilist = Magick::ImageList.new
    ilist.from_blob(blob)
    ilist.display

#### See also

to_blob, Image#to_blob, Image.from_blob

#### Magick API

BlobToImageList

### fx

ilist .fx(expression [, channel...]) -> image

#### Description

Applies the specified mathematical expression to the input images. This method corresponds to ImageMagick's -fx operator.

#### Arguments

expression
  A mathematical expression of the form accepted by the -fx operator..
channel...
  0 or more ChannelType arguments. Specify the output channels. If no channels are specified the result is set over all channels except the opacity channel.

#### Notes

- Fx expressions are interpreted. Therefore this method can be quite slow depending on the complexity of the expression. Generally you will get better performance by accessing the image pixels as Pixel objects (see get_pixels and view) and using Ruby code to perform the mathematics.
- The `u` and `v` symbols refer to the 0th and 1st image in the list. The image reference index (`u[2]` for example) works as expected. The current scene number has no meaning in the context of the `fx` method.
- To specify a non-default pixel interpolation method, set the pixel_interpolation_method attribute of the last image in the list.

#### Returns

The image created by the expression.

#### Example

    # Produce a navy blue image from a black image
    imgl = Magick::ImageList.new
    imgl << Magick::Image.new(64, 64) {self.background_color = 'black'}

    res = imgl.fx('1/2', Magick::BlueChannel)

#### ImageMagick API

FxImageChannel

#### See also

get_pixels, view

### inspect

ilist.inspect -> string

#### Description

Produces a string that describes the images in the imagelist.

#### Arguments

#### Returns

The returned string is a concatenation of the strings returned by Image#inspect for all the images in the imagelist.

#### Example

    i = Magick::ImageList.new("images/Button_A.gif", "images/Button_B.gif")
    » [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

#### See also

Image#inspect

### map

ilist.map(reference, dither) -> imagelist

#### Description

Reduces the colors in the imagelist images to the set of colors in the reference image.

#### Arguments

reference
  An image or a imagelist. If an imagelist, `map` uses the current image as the reference image.
dither
  if `true`, dither the mapped images.

#### Returns

A new imagelist the same length as the receiver.

#### Notes

This method is deprecated when using ImageMagick 6.4.3-6 and later. Use remap instead.

#### See also

Image#map, quantize

#### Magick API

MapImages

### montage

ilist.montage [ { optional arguments } ] -> imagelist

#### Description

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 tile).

All of `montage`'s configuration options are specified by assigning values to attributes in a block associated with the method call.

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

You may assign a Pixel object to any attribute that accepts a color name.

#### Montage attributes

background_color=
  The composite image background color.
border_color=
  The tile border color.
border_width=
  The tile border width in pixels.
compose=
  The composite operator to use when compositing the tile images onto the background. The default composition operator is `OverCompositeOp`.
  Hint: You can use a different composite operator for each tile by setting each image's compose= attribute to the desired operator. In the optional arguments block, set `compose` to UndefinedCompositeOp.
fill=
  If the tiles have labels, the label fill color. The default fill color is black.
font=
  If the tiles have labels, the label font. The default font is Helvetica.
frame=
  The size of an ornamental frame surrounding each tile. The frame specification may be either a string or a Geometry object. If the argument is a string, it must have the form `<width>x<height>+<outer bevel width>+<inner bevel width>`. If the argument is a Geometry object, specify the width and height of the frame with the `width` and `height` attributes, and specify the outer bevel width and the inner bevel width with the `x` and `y` 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:

      self.frame = "20x20+4+4"

  or

      self.frame = Magick::Geometry.new(20,20,4,4)

  If the tile has a label, the label is included in the frame. The default is to have no frame.
  See Image#frame.
geometry=
  The size of the tiles and the distance between tiles. The value can be either a geometry string or a Geometry object. The geometry string has the form: `<tile-width>x<tile-height>+<distance-between-columns>+<distance-between-rows>`. If you use a Geometry object, specify the tile width and height with the `width` and `height` attributes, and the distance between rows and distance between columns by the `x` and `y` 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:

      self.geometry = "130x194+10+5"

  or

      self.geometry = Magick::Geometry.new(130, 194, 10, 5)

  Both the geometry string and the `Geometry` object support flags that specify additional constraints. The default geometry is "120x120+4+3>".
gravity=
  The direction used when adding the tile labels. (See annotate.)
matte_color=
  The matte color. The default is #bdbdbd.
pointsize=
  If the tiles have labels, the size of the label font in points. The default is 12 points.
shadow=
  If set to `true`, adds a drop shadow to each tile. The default is `false`.
stroke=
  If the tiles have labels, sets the stroke (outline) color of the label text. The default is "transparent".
texture=
  A image to be tiled on the background of the composite image. If present, this attribute overrides the background color. For example, to use ImageMagick's built-in "granite" texture as the background, use:

      self.texture = Magick::Image.read("granite:").first

  The default is no texture.

tile=
  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 Geometry object. If the value is a string, it should have the form `"<columns>x<rows>"`. If the value is a Geometry object, specify the number of columns as the `width` attribute and the number of rows as the `height` attribute. `montage` always generates all the rows, leaving empty cells if necessary. To arrange the tiles 4 across and 10 down, use:

      self.tile = "4x10"

  or

      self.tile = Magick::Geometry.new(4,10)

  The default is "6x4". If there are too many tiles to fit on one composite image, `montage` creates multiple composite images.

title=
  Adds a title over the whole montage.

#### Tile labels

To add labels to the tiles, assign a "Label" property to each image. The `montage` method will use the value of the property as the label. For example,

    img[2]['Label'] = "Mom's Birthday"

See []=.

#### Returns

An imagelist that contains as many images as are required to display all the tiles.

#### Magick API

MontageImages

### morph

ilist.morph(n) -> imagelist

#### Description

Transforms a image into another image by inserting `n` 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.

#### Arguments

The number of in-between images to insert between each pair of images.

#### Returns

An imagelist containing copies of the original images plus the in-between images.

#### Example

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

#### Magick API

MorphImages

### mosaic

ilist.mosaic -> image

#### Description

Composites all the images into a single new image. The location of each image is determined by the value of its page attribute.

#### Returns

An image

#### Example

#### See also

coalesce, flatten_images, montage, optimize_images

#### Magick API

MergeImageLayers with the MosaicLayer method.

### new_image

ilist.new_image(columns, rows[, fill]) [ { optional arguments } ] -> self

#### Description

Adds a new image to the imagelist. The image can have an optional fill applied to it.

#### Arguments

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

You can set any Image::Info attributes in an associated block. These attributes supply options to be used when creating the image. For example, you can specify the background color to fill the image with (see the example), the depth, border color, etc.

#### Returns

self

#### Example

Create a square red image.

    ilist = Magick::ImageList.new
    ilist.new_image(100, 100) { self.background_color = "red" }

### optimize_layers

ilist.optimize_layers(layer_method) -> imagelist

#### Description

Optimizes or compares the images in the list. Equivalent to the `-layers` option in ImageMagick's `mogrify` command.

The `optimize_layers` method corresponds to the `-layers` option on ImageMagick's `convert` and `mogrify` commands. Anthony Thyssen's excellent Examples of ImageMagick Usage site has very detailed information and examples of the `-layers` option and and the optimization methods .

#### Arguments

One of the following ImageLayerMethod enum values:

CoalesceLayer
  Equivalent to [coalesce]. Apply the GIF disposal methods set in the current image sequence to form a fully defined animation sequence without, as it should be displayed. Effectively converting a GIF animation into a 'film strip' like animation.
CompareAnyLayer
  Crop the second and later frames to the smallest rectangle that contains all the differences between the two images. No GIF disposal methods are taken into account. This is exactly the same as [deconstruct], and does not preserve a animation's normal working, especially when a animation used GIF disposal methods such as 'Previous' or 'Background'.
CompareClearLayer
  As [CompareAnyLayer] but crop to the bounds of any opaque pixels which become transparent in the second frame. That is the smallest image needed to mask or erase pixels for the next frame.
CompareOverlayLayer
  As [CompareAnyLayer] but crop to pixels that add extra color to the next image, as a result of overlaying color pixels. That is the smallest single overlaid image to add or change colors. This can, be used with the -compose alpha composition method 'change-mask', to reduce the image to just the pixels that need to be overlaid.
DisposeLayer
  This is like [CoalesceLayer] but shows the look of the animation after the GIF disposal method has been applied, before the next sub-frame image is overlaid. That is the 'dispose' image that results from the application of the GIF disposal method. This allows you to check what is going wrong with a particular animation you may be developing.
FlattenLayer
  Create a canvas the size of the first images virtual canvas using the current background color, and compose each image in turn onto that canvas. Images falling outside that canvas will be clipped. Final image will have a zero virtual canvas offset. This is usually used as one of the final 'image layering' operations overlaying all the prepared image layers into a final image. For a single image this method can also be used to fillout a virtual canvas with real pixels, or to underlay a opaque color to remove transparency from an image. This method corresponds to flatten_images, above.
MergeLayers
  As [FlattenLayer] but merging all the given image layers into a new layer image just large enough to hold all the image without clipping or extra space. The new image's virtual offset will prevere the position of the new layer, even if this offset is negative. the virtual canvas size of the first image is preserved. Caution is advised when handling image layers with negative offsets as few image file formats handle them correctly.
MosaicLayer
  As [FlattenLayer] but expanding the initial canvas size of the first image so as to hold all the image layers. However as a virtual canvas is 'locked' to the origin, by definition, image layers with a negative offsets will still be clipped by the top and left edges. This method is commonly used to layout individual image using various offset but without knowing the final canvas size. The resulting image will, like FlattenLayer not have any virtual offset, so can be saved to any image file format. This method corresponds to mosaic, above.
OptimizeImageLayer
  Optimize a coalesced animation into GIF animation by reducing the number of pixels per frame as much as possible by attempting to pick the best GIF disposal method to use, while ensuring the result will continue to animate properly. There is no guarantee that the best optimization will be found. But then no reasonably fast GIF optimization algorithm can do this. However this does seem to do better than most other GIF frame optimizers seen.
OptimizeLayer
  Optimize a coalesced animation into GIF animation using a number of general techniques. This is currently a short cut to apply both the [OptimizeImageLayer] and [OptimizeTransLayer] methods but will expand to include other methods.
OptimizePlusLayer
  As [OptimizeImageLayer] but attempt to improve the overall optimization by adding extra frames to the animation, without changing the final look or timing of the animation. The frames are added to attempt to separate the clearing of pixels from the overlaying of new additional pixels from one animation frame to the next. If this does not improve the optimization (for the next frame only), it will fall back to the results of the previous normal [OptimizeImageLayer] technique. There is the possibility that the change in the disposal style will result in a worsening in the optimization of later frames, though this is unlikely. In other words there no guarantee that it is better than the normal 'optimize-frame' technique.
OptimizeTransLayer
  Given a GIF animation, replace any pixel in the sub-frame overlay images with transparency, if it does not change the resulting animation by more than the current fuzz factor. This should allow a existing frame optimized GIF animation to compress into a smaller file size due to larger areas of one (transparent) color rather than a pattern of multiple colors repeating the current disposed image of the last frame.
RemoveDupsLayer
  Remove (and merge time delays) of duplicate consecutive images, so as to simplify layer overlays of coalesced animations. Usually this is a result of using a constant time delay across the whole animation, or after a larger animation was split into smaller sub-animations. The duplicate frames could also have been used as part of some frame optimization methods.
RemoveZeroLayer
  Remove any image with a zero time delay, unless ALL the images have a zero time delay (and is not a proper timed animation, a warning is then issued). In a GIF animation, such images are usually frames which provide partial intermediary updates between the frames that are actually displayed to users. These frames are usually added for improved frame optimization in GIF animations.
TrimBoundsLayer
  Find the minimal bounds of all the images in the current image sequence, then adjust the offsets so all images are contained on a minimal positive canvas. None of the image data is modified, only the virtual canvas size and offset. Then all the images will have the same canvas size, and all will have a positive offset, at least one image will touch every edge of that canvas with actual pixel data, though that data may be transparent.

Some of these values are not supported by older versions of ImageMagick. To see what values are available, enter the following code in irb:

    Magick::ImageLayerMethod.values {|v| puts v}

In releases of ImageMagick before 6.3.6, this type was called MagickLayerMethod, so you may need to use this instead:

    Magick::MagickLayerMethod.values {|v| puts v}

#### Returns

A new imagelist

#### See also

composite_layers

deconstruct is an alias for `optimize_layers` with the `CompareAnyLayer` argument.

coalesce is an alias for `optimize_layers` with the `CoalesceLayer` argument.

#### Magick API

OptimizeImageLayers, CompareImageLayers

### ping

ilist.ping(filename[, filename...]) -> self
ilist.ping(file[, file...]) -> self

#### Description

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 `ping` method is much faster and consumes less memory than `read`.

#### Arguments

One or more image file names or open file objects.

#### Returns

self

#### Example

    ilist = Magick::ImageList.new
    ilist.ping "Button_A.gif"
    puts "The image has #{i.columns} columns and #{i.rows} rows." »
          The image has 127 columns and 120 rows.

#### See also

read

#### Magick API

PingImage

### quantize

ilist.quantize(nc=256, colorspace=`RGBColorspace`, dither=`RiemersmaDitherMethod`, tree_depth=0, measure_error=`false`) -> imagelist

#### Description

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.

#### Arguments

nc
  The maximum number of colors to use in the output images. Must be less than or equal to QuantumRange.
colorspace
  The colorspace 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.
dither
  A DitherMethod value. See the documentation for the ImageMagick -dither option for more information.
tree_depth
  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.
measure_error
  Calculate quantization errors when quantizing the image. Stores the results for each image in the imagelist mean_error_per_pixel, normalized_maximum_error, and normalized_mean_error attributes. Stores the number of colors used for the image in the total_colors attribute.

#### Returns

A new imagelist containing quantized copies of the images in the original image.

#### Example

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.

#### See also

Image#quantize

#### Magick API

QuantizeImages

### read

ilist.read(filename[, filename...]) [ { optional arguments } ] -> self
ilist.read(file[, file...]) [ { optional arguments } ] -> self

#### Description

Reads one or more image files and adds the images to the imagelist. After reading all the files, sets the scene number to the last image in the list.

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

#### Arguments

One or more filenames or open file objects. You can also specify optional arguments to be used when reading the file(s) by setting Image::Info attributes in the optional block.

#### Returns

self

#### Example

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

Also see the morph.rb example and the demo.rb example.

#### See also

Image.read

#### Magick API

ReadImage

#### Notes

You can create images using ImageMagick's built-in formats with the `read` method. See Built-in image formats.

### remap

ilist.remap(remap_image=nil, dither=RiemersmaDitherMethod) -> self

#### Description

Reduce the colors used in the imagelist to the set of colors in remap_image.

#### Arguments

remap_image
  The reference image
dither
  A DitherMethod value. RiemersmaDitherMethod is the default. To disable dithering specify NoDitherMethod.

#### Returns

self

#### Example

This example shows the effect of reducing the colors used in the apple, beach scene, and leaf images to the set of colors used in the yellow rose image.

#### See also

Image#remap

#### Magick API

RemapImages (available in ImageMagick 6.4.3-6)

### to_blob

ilist.to_blob [ { optional arguments } ] -> string

#### Description

Converts the images in the imagelist to a blob. A blob contains data that directly represent a particular image format in memory instead of on disk.

Control the format of the blob by setting Image::Info attributes in an associated block.

#### Returns

The blob in the form of a string

#### Example

    i = Magick::ImageList.new "birthday.png"
    s = i.to_blob » a string representing the image.

#### See also

from_blob, Image#to_blob, Image.from_blob

#### Magick API

ImageListToBlob

### to_a

ilist.to_a -> array

#### Description

Returns an array containing all the images in the list.

#### Returns

An array

### write

ilist.write(filename) [ { optional arguments } ] -> self
ilist.write(file) [ { optional arguments } ] -> self

#### Description

If the image format indicated by the filename supports multiple images per file (animated images), `write` writes all the images in the imagelist to a single file. Otherwise, `write` writes each image to a separate file.

Regardless of the original format, `write` converts the images to the format specified by the filename.

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.

#### Arguments

A filename or open file object. Indicate the desired image format either by the suffix (i.e. `.jpg`, `.png`) or the prefix (`ps:`) 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 format attribute. (See the Notes section for Image#write.)

You can also specify optional arguments by setting Image::Info attributes in an associated block.

#### Returns

self, or `nil` if the format cannot be determined.

#### Example

    # 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 » 3 # contains 3 images
    i.write "test.png" » test.png.0
                       » test.png.1
                       » test.png.2
    # ImageMagick's MIFF format does support multi-frame
    # files, so all 3 images are written to one file.
    i.write "animated.miff" » animated.miff

#### See also

Image#write

#### Magick API

WriteImages