Class: AppstormConcatenator::Concatenator

Inherits:
Object
  • Object
show all
Includes:
Magick
Defined in:
lib/appstorm_concatenator/concatenator.rb

Class Method Summary collapse

Class Method Details

.concatenate_images(image_1, image_2, output) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/appstorm_concatenator/concatenator.rb', line 7

def self.concatenate_images(image_1, image_2, output)
  # Create the canvas
  canvas = Image.new(620, 465) { self.background_color = "black" }

  # Images
  puts "--> Loading #{ARGV[0]}"
  img = Image.read(ARGV[0]).first

  puts "--> Loading #{ARGV[1]}"
  img2 = Image.read(ARGV[1]).first

  puts "--> Resizing images"
  img.resize! 305, 458
  img2.resize! 305, 458

  puts "--> Creating final image #{ARGV[2]}"
  canvas.composite(img, 3, 3, OverCompositeOp).composite(img2, 312, 3, OverCompositeOp).write(ARGV[2])

  puts "--> Done!"
  system "open #{ARGV[2]}" if !!(RUBY_PLATFORM =~ /darwin/)
end