2015-03-29 14:15:05 +00:00
|
|
|
require 'open3'
|
|
|
|
|
|
|
|
class Rasterizer
|
|
|
|
|
2017-01-11 14:25:48 +00:00
|
|
|
BINARY_PATH = (Rails.root + "a2png" + "a2png.sh").to_s
|
2015-03-29 14:15:05 +00:00
|
|
|
|
2017-01-11 18:06:38 +00:00
|
|
|
def generate_image(asciicast_url, out_path, time, scale, theme)
|
|
|
|
o, e, t = Open3.capture3("#{BINARY_PATH} -s #{scale} -t #{theme} '#{asciicast_url}' '#{out_path}' #{time}")
|
2015-03-29 14:15:05 +00:00
|
|
|
|
|
|
|
if t.exitstatus != 0
|
2017-01-11 14:25:48 +00:00
|
|
|
raise RuntimeError, "Couldn't generate image from #{asciicast_url}:\n#{o}\n#{e}"
|
2015-03-29 14:15:05 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|