Class: QuickMagick::ImageList

Inherits:
Object
  • Object
show all
Defined in:
lib/quick_magick/image_list.rb

Instance Method Summary collapse

Constructor Details

#initialize(*filenames) ⇒ ImageList

Returns a new instance of ImageList.



4
5
6
7
8
# File 'lib/quick_magick/image_list.rb', line 4

def initialize(*filenames)
  @images = filenames.inject([]) do |image_list, filename|
    image_list + QuickMagick::Image.read(filename)
  end
end

Instance Method Details

#<<(more_images) ⇒ Object



48
49
50
51
52
53
54
55
56
57
# File 'lib/quick_magick/image_list.rb', line 48

def <<(more_images)
  case more_images
    when QuickMagick::Image then @images << more_images
    # Another image list
    when QuickMagick::ImageList then self << more_images.to_a
    when Array then @images += more_images
    else raise QuickMagick::QuickMagickError, "Invalid argument type"
  end
  self
end

#save(output_filename) ⇒ Object Also known as: write

Saves all images in the list to the output filename



31
32
33
34
35
36
37
# File 'lib/quick_magick/image_list.rb', line 31

def save(output_filename)
  command_line = ""
  @images.each do |image|
    command_line << image.command_line
  end
  `convert #{command_line} "#{output_filename}"`
end

#to_aryObject Also known as: to_a

Returns an array of images for the images stored



42
43
44
# File 'lib/quick_magick/image_list.rb', line 42

def to_ary
  @images
end