#!/usr/bin/ruby

indir  = "./figs-pdf"
outdir = "./figs-png"

if !Dir.exist?(indir)
  print 'Directory, ', indir, ', does not exist.', "\n"
  exit
end
if !Dir.exist?(outdir)
  print 'Directory, ', outdir, ', does not exist.', "\n"
  exit
end

Dir::foreach(indir) {|fn|
  if fn != "." && fn != ".." then
    infn = indir + "/" + fn
    outfn = outdir + "/" + fn[0..-5] + ".png"
    com = "convert -rotate 90 -background white -flatten " + infn + " " + outfn
    puts com
    system(com)
  end
}
