How to take screenshot of a website with Rails 3.1? -- without using a service
There is a Rails gem for this task.
gem install selenium-webdriver
Simple use case:
require 'selenium-webdriver' width = 1024 height = 728 driver = Selenium::WebDriver.for :firefox driver.navigate.to 'http://domain.com' driver.execute_script %Q{ window.resizeTo(#{width}, #{height}); } driver.save_screenshot('/tmp/screenshot.png') driver.quit
You could use wkhtmltoimage to load up the webpage and save it as an image, then imagemagick, (or one of the ruby wrappers for it) to crop it.
wkhtmltoimage www.google.com output.jpgconvert -crop 100x100+0+100 output.jpg cropped.jpg
There isn't a prebuilt wkhtmltoimage binary for OSX though, so perhaps you may want to use wkhtmltopdf instead and then imagemagick to convert to an image.
wkthmltopdf www.google.com output.pdfconvert -crop 100x100+0+100 output.pdf cropped.jpg