#!/usr/bin/env ruby

require "getoptlong"

parser = GetoptLong.new
parser.set_options(
                   ###    global option   ###
                   ['--DelTime',      GetoptLong::REQUIRED_ARGUMENT],
                   ['--Time',         GetoptLong::REQUIRED_ARGUMENT],
                   ['--info',         GetoptLong::REQUIRED_ARGUMENT],
                   ['--Num',          GetoptLong::REQUIRED_ARGUMENT]
                   )
begin
  parser.each_option do |name, arg|
    eval "$OPT_#{name.sub(/^--/, '').gsub(/-/, '_')} = '#{arg}'" 
  end
    rescue
  exit(1)
end

file = ARGV[0]
info = $OPT_info
time0= $OPT_Time.to_f
num  = $OPT_Num.to_f
delt = $OPT_DelTime.to_f

# ¿Þ¤ÎÅý¹ç
order = Math::log10(time0+delt*num).to_i + 1 
fmt = "%0"+(order.to_i).to_s+"d"  

for l in 0..num
  time = sprintf(fmt, time0.to_f+(l*delt).to_f)
  out  = sprintf("%03d", l+1)
  
  outputfile  = info+"_"+out.to_s+".jpg"  
  outputfile1 = info+"-1_t"+time.to_s+".png"  
  outputfile2 = info+"-2_t"+time.to_s+".png"  

  convert1 = "convert +append "+outputfile2+" "+outputfile1+" "+outputfile
  system( convert1 )
  p convert1  

end
