<- Prev | Contents | Next -> |
Table Of Contents |
|||||||||||||||||||||||||||||||||||||
class methodsinstance attribute methodsinstance methods |
|||||||||||||||||||||||||||||||||||||
class methods |
|||||||||||||||||||||||||||||||||||||
new | Magick::ImageList.new -> image Magick::ImageList.new(filename[, filename...]]) -> image |
||||||||||||||||||||||||||||||||||||
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. | ||||||||||||||||||||||||||||||||||||
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") |
||||||||||||||||||||||||||||||||||||
instance attribute accessor methods |
|||||||||||||||||||||||||||||||||||||
delay= | imagelist.delay=n | ||||||||||||||||||||||||||||||||||||
Description | Sets the length of time that each image in the imagelist will be displayed when the sequence is animated. | ||||||||||||||||||||||||||||||||||||
Arguments | An integer value representing the number of 100ths of a second to display each image. | ||||||||||||||||||||||||||||||||||||
Returns | self | ||||||||||||||||||||||||||||||||||||
Example |
imagelist.delay = 20 # delay 1/5 of a second between images. |
||||||||||||||||||||||||||||||||||||
×Magick notes | Image Structure Members | ||||||||||||||||||||||||||||||||||||
See also | Image#delay= | ||||||||||||||||||||||||||||||||||||
Advanced | The ImageList class delay= attribute assigns the same delay to all the images in the imagelist. Use Image#delay= to set different delay values on individual images. | ||||||||||||||||||||||||||||||||||||
iterations= | imagelist.iterations=n | ||||||||||||||||||||||||||||||||||||
Description | Sets the number of times an animated image should loop. | ||||||||||||||||||||||||||||||||||||
Arguments | The number of iterations | ||||||||||||||||||||||||||||||||||||
Example |
imagelist.iterations = 10 |
||||||||||||||||||||||||||||||||||||
×Magick notes | Image Structure Members | ||||||||||||||||||||||||||||||||||||
Notes | The animate 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 of iterations. | ||||||||||||||||||||||||||||||||||||
length | imagelist.length -> anInteger | ||||||||||||||||||||||||||||||||||||
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= |
scene -> anInteger scene=anInteger |
||||||||||||||||||||||||||||||||||||
Description | Get or set the current scene number. The scene number indicates the image to which Image methods are sent. | ||||||||||||||||||||||||||||||||||||
Example |
imagelist.scene = 10 imagelist.scene » 10 |
||||||||||||||||||||||||||||||||||||
instance methods |
|||||||||||||||||||||||||||||||||||||
Array methods | |||||||||||||||||||||||||||||||||||||
Description |
You can manipulate the images in an imagelist using almost any
Array method. Many of these methods will 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.
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.
|
||||||||||||||||||||||||||||||||||||
Example |
Add noise to a model image. Append the resulting image to
the imagelist in "example". (See: demo.rb)
example = Magick::ImageList.new model = Magick::ImageList.new "model.miff" example << model.add_noise Magick::LaplacisanNoise |
||||||||||||||||||||||||||||||||||||
See also | scene scene= |
||||||||||||||||||||||||||||||||||||
Advanced |
The assoc, flatten, flatten!, join, pack, and rassoc methods are not defined in the ImageList class. Array methods defined in the ImageList class that would normally return an array return an ImageList. Adding anything other than a image to an imagelist has undefined results. Most of the time RMagick will raise an ArgumentError exception. |
||||||||||||||||||||||||||||||||||||
<=> | imagelist <=> anOtherImageList -> -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 recipient (a)
and the other (b) is performed this way:
|
||||||||||||||||||||||||||||||||||||
See also | Image#<=> | ||||||||||||||||||||||||||||||||||||
Advanced |
Individual images are compared by comparing their signatures.
|
||||||||||||||||||||||||||||||||||||
animate | imagelist.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. | ||||||||||||||||||||||||||||||||||||
Arguments | None | ||||||||||||||||||||||||||||||||||||
Example |
imagelist.animate |
||||||||||||||||||||||||||||||||||||
×Magick API | AnimateImages | ||||||||||||||||||||||||||||||||||||
See also | display | ||||||||||||||||||||||||||||||||||||
append | imagelist.append(true or
false ) -> anImage |
||||||||||||||||||||||||||||||||||||
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. | ||||||||||||||||||||||||||||||||||||
Example | See the map example. | ||||||||||||||||||||||||||||||||||||
×Magick API | AppendImages | ||||||||||||||||||||||||||||||||||||
average | imagelist.average -> anImage | ||||||||||||||||||||||||||||||||||||
Description | Averages all the images together. Each image in the image must have the same width and height. | ||||||||||||||||||||||||||||||||||||
Arguments | None | ||||||||||||||||||||||||||||||||||||
Returns | A single image representing the average of all the images in the imagelist. | ||||||||||||||||||||||||||||||||||||
Example | ![]() |
||||||||||||||||||||||||||||||||||||
×Magick API | AverageImages | ||||||||||||||||||||||||||||||||||||
coalesce | imagelist.coalesce -> anImageList | ||||||||||||||||||||||||||||||||||||
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. |
||||||||||||||||||||||||||||||||||||
Arguments | None | ||||||||||||||||||||||||||||||||||||
Returns | A new multi-frame image. | ||||||||||||||||||||||||||||||||||||
Example |
|
||||||||||||||||||||||||||||||||||||
×Magick API | CoalesceImages | ||||||||||||||||||||||||||||||||||||
See also | flatten_images | ||||||||||||||||||||||||||||||||||||
copy | imagelist.copy -> anImageList | ||||||||||||||||||||||||||||||||||||
Description | Creates a deep copy of the imagelist. The new imagelist contains a copy of all the images in the original imagelist. | ||||||||||||||||||||||||||||||||||||
Arguments | None | ||||||||||||||||||||||||||||||||||||
Returns | A new image. | ||||||||||||||||||||||||||||||||||||
Example |
imagelist2 = imagelist1.copy |
||||||||||||||||||||||||||||||||||||
See also | Image#copy | ||||||||||||||||||||||||||||||||||||
cur_image | imagelist.cur_image -> anImage | ||||||||||||||||||||||||||||||||||||
Description | Retrieves the image indexed by scene. | ||||||||||||||||||||||||||||||||||||
Arguments | None | ||||||||||||||||||||||||||||||||||||
Returns | The image in the images array indexed by the current value of scene. | ||||||||||||||||||||||||||||||||||||
Example |
f = imagelist.cur_image |
||||||||||||||||||||||||||||||||||||
Advanced | 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 RubyMagick 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. | ||||||||||||||||||||||||||||||||||||
deconstruct | imagelist.deconstruct -> anImage | ||||||||||||||||||||||||||||||||||||
Description | Compares each image with the next in a sequence and returns the maximum bounding region of any pixel differences it discovers. | ||||||||||||||||||||||||||||||||||||
Arguments | None. | ||||||||||||||||||||||||||||||||||||
Returns | A image. | ||||||||||||||||||||||||||||||||||||
Example |
f = imagelist.deconstruct |
||||||||||||||||||||||||||||||||||||
×Magick API | DeconstructImages | ||||||||||||||||||||||||||||||||||||
Other | I'm looking for an example. | ||||||||||||||||||||||||||||||||||||
display | imagelist.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. | ||||||||||||||||||||||||||||||||||||
Arguments | None | ||||||||||||||||||||||||||||||||||||
Example |
imagelist.display imagelist.display { self.server_name = "other.lnx:0.0" } |
||||||||||||||||||||||||||||||||||||
×Magick API | DisplayImages | ||||||||||||||||||||||||||||||||||||
See also | animate | ||||||||||||||||||||||||||||||||||||
flatten_images | imagelist.flatten_images -> anImage | ||||||||||||||||||||||||||||||||||||
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. | ||||||||||||||||||||||||||||||||||||
Arguments | None | ||||||||||||||||||||||||||||||||||||
Returns | A image that is the combination of all the images in the image. | ||||||||||||||||||||||||||||||||||||
Example | ![]() |
||||||||||||||||||||||||||||||||||||
×Magick API | FlattenImageList | ||||||||||||||||||||||||||||||||||||
See also | coalesce | ||||||||||||||||||||||||||||||||||||
Advanced | This is useful for combining Photoshop layers into a single image. | ||||||||||||||||||||||||||||||||||||
Notes | Since the Array class defines a flatten method I used a different name for this method. | ||||||||||||||||||||||||||||||||||||
from_blob | imagelist.from_blob(blob[, blob...]) [ { optional arguments } ] -> self | ||||||||||||||||||||||||||||||||||||
Description | Creates images from the blob (Binary Large Objects) arguments and appends the images to the imagelist in the image. | ||||||||||||||||||||||||||||||||||||
Arguments | One or more of the strings produced by to_blob. Control the format of the created image(s) by setting additional Image::Info attributes in the optional block argument. Useful attributes include format, size, and depth. | ||||||||||||||||||||||||||||||||||||
Returns | An image created from the blob argument(s). The scene attribute is set to the last image in the image. | ||||||||||||||||||||||||||||||||||||
Example |
imagelist = Magick::ImageList.new imagelist.from_blob(blob) { self.format = "GIF" self.size = "120x120" self.depth = Magick::QuantumDepth } |
||||||||||||||||||||||||||||||||||||
×Magick API | BlobToImageList | ||||||||||||||||||||||||||||||||||||
See also | to_blob Image#to_blob Image.from_blob |
||||||||||||||||||||||||||||||||||||
inspect | imagelist.inspect -> aString | ||||||||||||||||||||||||||||||||||||
Description | Produces a string that describes the images in the image. | ||||||||||||||||||||||||||||||||||||
Arguments | None | ||||||||||||||||||||||||||||||||||||
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") imagelist.inspect » "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" |
||||||||||||||||||||||||||||||||||||
×Magick notes | Produces essentially the same information as DescribeImageList | ||||||||||||||||||||||||||||||||||||
See also | Image#inspect | ||||||||||||||||||||||||||||||||||||
map | imagelist.map(reference, dither) -> anImageList | ||||||||||||||||||||||||||||||||||||
Description | Reduces the colors in the imagelist images to the set of colors in the reference image. | ||||||||||||||||||||||||||||||||||||
Arguments |
|
||||||||||||||||||||||||||||||||||||
Returns | A new imagelist containing one image for every image in the receiver. | ||||||||||||||||||||||||||||||||||||
Example | |||||||||||||||||||||||||||||||||||||
×Magick API | MapImages | ||||||||||||||||||||||||||||||||||||
See also | Image#map quantize |
||||||||||||||||||||||||||||||||||||
montage | imagelist.montage [ { optional arguments } ] -> anImageList | ||||||||||||||||||||||||||||||||||||
Description |
Creates a composite image by reducing the size of the
image 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
(tile).
All of montage's configuration options are specified by assigning values to attribute methods in a block associated with the method call. |
||||||||||||||||||||||||||||||||||||
Configuration attributes |
Note:In the above examples, the reference to self is necessary to distinguish the method call from an assignment to a local variable. Note:You may assign a Pixel object to any attribute that accepts a color name. |
||||||||||||||||||||||||||||||||||||
Tile labels |
To add labels to the tiles, assign a "Label" attribute to
each image. The montage method will use the
value of the attribute as the tile's label. For example,
img[2]['Label'] = "Mom's Birthday"See Image#[]=. |
||||||||||||||||||||||||||||||||||||
×Magick API | MontageImages | ||||||||||||||||||||||||||||||||||||
Returns | An image containing as many images as were necessary to tile all the images in the original image. | ||||||||||||||||||||||||||||||||||||
Example | demo.rb | ||||||||||||||||||||||||||||||||||||
See also | The ×Magick montage utility | ||||||||||||||||||||||||||||||||||||
morph | imagelist.morph(n) -> anImageList | ||||||||||||||||||||||||||||||||||||
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 |
|
||||||||||||||||||||||||||||||||||||
×Magick API | MorphImages | ||||||||||||||||||||||||||||||||||||
mosaic | imagelist.mosaic -> anImage | ||||||||||||||||||||||||||||||||||||
Description | Composites all the images into a single new image. The location of each image is determined by the value of its page attribute. | ||||||||||||||||||||||||||||||||||||
Arguments | None | ||||||||||||||||||||||||||||||||||||
Returns | A new image. | ||||||||||||||||||||||||||||||||||||
Example | ![]() |
||||||||||||||||||||||||||||||||||||
×Magick API | MosaicImages | ||||||||||||||||||||||||||||||||||||
See also | coalesce flatten_images montage |
||||||||||||||||||||||||||||||||||||
new_image | imagelist.new_image(columns, rows[, fill]) [ { optional arguments } ] | ||||||||||||||||||||||||||||||||||||
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. imagelist = Magick::ImageList.new imagelist.new_image(100, 100) { self.background_color = "red" } |
||||||||||||||||||||||||||||||||||||
ping | imagelist.ping(filename[, filename...]) -> 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. | ||||||||||||||||||||||||||||||||||||
Returns | self | ||||||||||||||||||||||||||||||||||||
Example |
imagelist = Magick::ImageList.new imagelist.ping "Button_A.gif" puts "The image has #{i.columns} columns and #{i.rows} rows." » The image has 127 columns and 120 rows. |
||||||||||||||||||||||||||||||||||||
×Magick API | PingImage | ||||||||||||||||||||||||||||||||||||
See also | read | ||||||||||||||||||||||||||||||||||||
quantize | imagelist.quantize(nc=256,
colorspace=Magick::RGBColorspace ,
dither=true , tree_depth=0,
measure_error=false ) ->
anImageList |
||||||||||||||||||||||||||||||||||||
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 |
|
||||||||||||||||||||||||||||||||||||
Returns | A new imagelist containing quantized copies of the images in the original image. | ||||||||||||||||||||||||||||||||||||
Example |
|
||||||||||||||||||||||||||||||||||||
×Magick API | QuantizeImages | ||||||||||||||||||||||||||||||||||||
See also | Image#quantize | ||||||||||||||||||||||||||||||||||||
read | imagelist.read(filename[, filename...])
[ { optional arguments } ] ->
self imagelist.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) 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! endSee the morph example and demo.rb. |
||||||||||||||||||||||||||||||||||||
×Magick notes | ReadImageList | ||||||||||||||||||||||||||||||||||||
See also | Image.read | ||||||||||||||||||||||||||||||||||||
Advanced | You can create images using ×Magick's built-in formats with the read method. See Built-in image formats. | ||||||||||||||||||||||||||||||||||||
to_blob | imagelist.to_blob [ { optional arguments } ] -> aString | ||||||||||||||||||||||||||||||||||||
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. | ||||||||||||||||||||||||||||||||||||
Arguments | None. You can control the format of the blob by setting Image::Info attributes in an associated block. | ||||||||||||||||||||||||||||||||||||
Returns | The blob in the form of a Ruby string. | ||||||||||||||||||||||||||||||||||||
Example |
i = Magick::ImageList.new "birthday.png" s = i.to_blob » a string representing the image. |
||||||||||||||||||||||||||||||||||||
×Magick API | ImageListToBlob | ||||||||||||||||||||||||||||||||||||
See also | from_blob Image#to_blob Image.from_blob |
||||||||||||||||||||||||||||||||||||
write | imagelist.write(filename) [ {
optional arguments } ] -> self imagelist.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, 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.
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 # ×Magick's MIFF format does support multi-frame # files, so all 3 images are written to one file. i.write "animated.miff" » animated.miff |
||||||||||||||||||||||||||||||||||||
×Magick API | WriteImages | ||||||||||||||||||||||||||||||||||||
See also | Image#write | ||||||||||||||||||||||||||||||||||||
Advanced |
If you want to write each image to a separate file using
a format that supports multi-frame files, loop over the
images individually and use the write method in the Image
class:
x = 'A' imagelist.each { |f| f.write "#{image}_#{x}.gif"; x.succ! } |
<- Prev | Contents | Next -> |