summaryrefslogtreecommitdiff
path: root/merge-hdr-batch
blob: eadd33c21f5bcfd9b0463c8bdc921e158af469b1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#!/usr/bin/env ruby

BILDROEHRE=File.dirname(__FILE__)
DIR=ARGV[0]
TONEMAP=ARGV[1]
GAMMA=ARGV[2].to_f
i = 0
while line = STDIN.gets
  fs = line.strip.split
  s = " -f #{DIR}"
  args = fs.join (" -f #{DIR}")
  skip = false
  fs.each { |f|
    exposure = `exiftool #{DIR}/#{f} 2>/dev/null | grep 'Shutter Speed Value' | cut -d ':' -f 2 | strips`
    begin
      args += " -w #{Rational(exposure).to_f}"
    rescue
      STDERR.write "Error, can't get exposure! Skipping #{line}."
      skip = true
      break
    end
  }
  next if skip
  is = i.to_s.rjust(3, "0")
  s += args
  cmd = "#{BILDROEHRE}/merge -D -R -g 1.0 -O debevec-#{TONEMAP}-gamma#{GAMMA}-#{is}.jpg -p robertston-#{TONEMAP}-gamma#{GAMMA}-#{is}.jpg #{s}"
  STDERR.write "#{cmd}\n"
  `#{cmd}`
  i += 1
end