Pass scale and theme to a2png
This commit is contained in:
parent
c89d363c9f
commit
747767da15
2
a2png
2
a2png
@ -1 +1 @@
|
|||||||
Subproject commit 3e6c81b8751074ef3d0160e9586b78b2293e169e
|
Subproject commit 9099a8fa26f79f73c58ceeb88276e9c539251bb0
|
@ -14,8 +14,9 @@ class AsciicastImageGenerator
|
|||||||
asciicast_url = asciicast.file.absolute_url
|
asciicast_url = asciicast.file.absolute_url
|
||||||
image_path = "#{dir}/#{asciicast.image_filename}"
|
image_path = "#{dir}/#{asciicast.image_filename}"
|
||||||
time = asciicast.snapshot_at || asciicast.duration / 2
|
time = asciicast.snapshot_at || asciicast.duration / 2
|
||||||
|
theme = AsciicastDecorator.new(asciicast).theme_name
|
||||||
|
|
||||||
generate_png_file(asciicast_url, image_path, time)
|
rasterizer.generate_image(asciicast_url, image_path, time, PIXEL_DENSITY, theme)
|
||||||
image_width, image_height = get_size(image_path)
|
image_width, image_height = get_size(image_path)
|
||||||
|
|
||||||
update_asciicast(asciicast, image_path, image_width, image_height)
|
update_asciicast(asciicast, image_path, image_width, image_height)
|
||||||
@ -24,10 +25,6 @@ class AsciicastImageGenerator
|
|||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def generate_png_file(asciicast_url, image_path, time)
|
|
||||||
rasterizer.generate_image(asciicast_url, image_path, time)
|
|
||||||
end
|
|
||||||
|
|
||||||
def get_size(image_path)
|
def get_size(image_path)
|
||||||
width, height = image_inspector.get_size(image_path)
|
width, height = image_inspector.get_size(image_path)
|
||||||
|
|
||||||
|
@ -4,8 +4,8 @@ class Rasterizer
|
|||||||
|
|
||||||
BINARY_PATH = (Rails.root + "a2png" + "a2png.sh").to_s
|
BINARY_PATH = (Rails.root + "a2png" + "a2png.sh").to_s
|
||||||
|
|
||||||
def generate_image(asciicast_url, out_path, time)
|
def generate_image(asciicast_url, out_path, time, scale, theme)
|
||||||
o, e, t = Open3.capture3("#{BINARY_PATH} '#{asciicast_url}' #{out_path} #{time}")
|
o, e, t = Open3.capture3("#{BINARY_PATH} -s #{scale} -t #{theme} '#{asciicast_url}' '#{out_path}' #{time}")
|
||||||
|
|
||||||
if t.exitstatus != 0
|
if t.exitstatus != 0
|
||||||
raise RuntimeError, "Couldn't generate image from #{asciicast_url}:\n#{o}\n#{e}"
|
raise RuntimeError, "Couldn't generate image from #{asciicast_url}:\n#{o}\n#{e}"
|
||||||
|
@ -9,7 +9,7 @@ describe AsciicastImageGenerator, needs_phantomjs_2_bin: true do
|
|||||||
let(:asciicast) {
|
let(:asciicast) {
|
||||||
create(
|
create(
|
||||||
:asciicast,
|
:asciicast,
|
||||||
theme_name: 'tango',
|
theme_name: 'asciinema',
|
||||||
file: Asciinema::FixtureHelpers.fixture_file('1/screenshot.json', 'application/json')
|
file: Asciinema::FixtureHelpers.fixture_file('1/screenshot.json', 'application/json')
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user