Sha256: 9ca4d61ded94f9451195602d1ed8a29ee7f9d63f7c383953b0e27e872c9952ea
Contents?: true
Size: 1.46 KB
Versions: 1
Compression:
Stored size: 1.46 KB
Contents
require 'tmpdir' module Thwomp # Renders SWF files module Renderers class SWF include Renderers::Helper attr_reader :filename, :frame_count, :width, :height def initialize(url, options={}) @filename = Downloader.new(url).filename @frame_count = options.fetch(:frame_count) { 10 } @width = options.fetch(:width) { 500 } @height = options.fetch(:height) { 500 } end def frames timestamp = Time.now.to_i Command.exec( "#{executable} -s1 --screenshot=#{frame_batch}" \ " --screenshot-file=#{output_file(timestamp)}" \ " -1 -r1 --timeout 200 #{filename} -j #{width}" \ " -k #{height} > /dev/null 2>&1" ) sort Dir.glob("#{Dir.tmpdir}/frame_#{timestamp}_*.png") end def frame(number) timestamp = Time.now.to_i Command.exec( "#{executable} -s1 --screenshot=#{number}" \ " --screenshot-file=#{output_file(timestamp)}" \ " -1 -r1 --timeout 200 #{filename} -j #{width}" \ " -k #{height} > /dev/null 2>&1" ) "#{Dir.tmpdir}/frame_#{timestamp}_#{number}.png" end def frame_batch batch = ['last'] + (0..frame_count).to_a.reverse batch.join(',') end def output_file(timestamp) "#{Dir.tmpdir}/frame_#{timestamp}_%f.png" end def executable Thwomp.gnash_path || "gnash-dump" end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
thwomp-0.1.0 | lib/thwomp/renderers/swf.rb |