Created
February 5, 2012 19:03
-
-
Save starmer/1747277 to your computer and use it in GitHub Desktop.
Create a diptych (combine two images together)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require 'rubygems' | |
| require 'RMagick' | |
| include Magick | |
| if ARGV.length < 4 | |
| puts "Usage: ruby diptych.rb <new image> <left image> <right image> <width>" | |
| else | |
| left_img = Image.read(ARGV[1])[0]; | |
| right_img = Image.read(ARGV[2])[0]; | |
| if(left_img.rows != right_img.rows) | |
| puts "Waring: The images aren't the same height" | |
| end | |
| image = Image.new(ARGV[3].to_i, right_img.rows.to_i) { | |
| self.background_color = "white" | |
| } | |
| image.composite!(left_img, 0, 0, OverCompositeOp) | |
| image.composite!(right_img, ARGV[3].to_i - right_img.columns.to_i, 0, OverCompositeOp) | |
| image.write(ARGV[0]) | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment