Skip to content

Instantly share code, notes, and snippets.

@luisparravicini
Created March 25, 2012 13:47
Show Gist options
  • Save luisparravicini/2194335 to your computer and use it in GitHub Desktop.
Save luisparravicini/2194335 to your computer and use it in GitHub Desktop.
Compose several images using ImageMagick
require 'fileutils'
include FileUtils
dir = ARGV.shift
method = ARGV.shift
if dir.nil? || method.nil?
puts "usage #{$0} <image-dir> <method>"
exit 1
end
out_path = "method_#{method}.jpg"
tmp_path = 'tmp.jpg'
files = Dir.glob(File.join(dir, '*.jpg'))
cp(files.pop, out_path)
offset = 1.to_f
files.each do |path|
print "%s\t%2.0f%%\r" % [File.basename(path), 100*offset/files.size]
offset += 1
out = `composite "#{path}" "#{out_path}" -compose #{method} "#{tmp_path}" 2>&1`
raise "error composing image: #{out}" unless $?.success?
mv(tmp_path, out_path)
end
@Haroenv
Copy link

Haroenv commented Nov 24, 2015

I've got the most success for a test night time-lapse with "lightenIntensity" as method, here what I came up with (this was a test by dusk I still had laying around):

method_lightenintensity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment