Sha256: d3c17a95c7c7b598f28d3324d0a1bbd3af95e63146b8a39df3e20a473aefc305
Contents?: true
Size: 582 Bytes
Versions: 32
Compression:
Stored size: 582 Bytes
Contents
require 'phantomjs' # See: http://www.thegreatcodeadventure.com/screen-capture-in-rails-with-phantomjs/ module Cosgrove module Phantomjs PATH_TO_PHANTOM_SCRIPT = "#{File.dirname(__FILE__)}/../../support/js/screencap.js" def take_screencap(url, filename = nil, width = 64, height = 64) target_path = Digest::MD5.hexdigest(filename || url.parameterize) target_path += '.png' Dir.chdir('/tmp') system "phantomjs #{PATH_TO_PHANTOM_SCRIPT} \"#{url}\" #{target_path} #{width} #{height}" File.open(target_path) end end end
Version data entries
32 entries across 32 versions & 1 rubygems