module Cosgrove::Phantomjs
Constants
- PATH_TO_PHANTOM_SCRIPT
Public Instance Methods
take_screencap(url, filename = nil, width = 64, height = 64)
click to toggle source
# File lib/cosgrove/phantomjs.rb, line 8 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