Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I take screenshots of web pages using ruby and a unix server? [closed]

I'm trying to programatically create thumbnail images of a large number of web pages that are hosted on my own ruby/rails-based website.

I want to be able to code a stand-alone bit of ruby that looks something like this:

require 'awesome-screenshot-maker'

items.each do |id|
  url = "http://foo.com/bar/#{id}"
  shooter = AwesomeScreenshotMaker.new(0.2) # thumbnails are 20% of original
  shooter.capture(url, "/images/thumbnail-#{id}.png")
end

I need the awesome-screenshot-maker library (and its dependencies) to be fairly easy to build on Linux, Solaris and Mac OS X. Ideally it will install with a single 'gem install' command.

I've spent the afternoon exploring various options, including Moz snap shooter, webkit2png and rbwebkitgtk. They are all in the right area, but none seem to work on all three platforms.

RMagick looks like a possible option if I'm willing to output PDFs from my rails app (instead of web pages), but that strikes me as hacky. It's also very laborious to get RMagic and imagemagick up and running on Mac OS X.

Does such a library exist that can easily be setup on three platforms?

like image 427
Lee Avatar asked Apr 07 '09 17:04

Lee


People also ask

Is there a way to take a screenshot of an entire webpage?

Also, you can press Ctrl+Shift+P on Windows or Command+Shift+P on Mac. Type screenshot into the search box. Select Capture full-size screenshot. Once Chrome takes the screenshot, it should save it into your Downloads folder.

How do you screenshot an entire page in Linux?

PrtSc – Save a screenshot of the entire screen to the “Pictures” directory. Shift + PrtSc – Save a screenshot of a specific region to Pictures. Alt + PrtSc – Save a screenshot of the current window to Pictures. Ctrl + PrtSc – Copy the screenshot of the entire screen to the clipboard.

How do you take a screen clipping from a website?

Press Ctrl + PrtScn keys. The entire screen changes to gray including the open menu. Select Mode, or in earlier versions of Windows, select the arrow next to the New button. Select the kind of snip you want, and then select the area of the screen capture that you want to capture.


2 Answers

Selenium RC has a Ruby interface and can grab a screenshot using capture_screenshot(filename,kwargs).

You'd then have to shrink it to a thumbnail.

like image 114
Gene Gotimer Avatar answered Oct 29 '22 03:10

Gene Gotimer


you might want to try this:

http://www.pageglimpse.com/

like image 38
NoCarrier Avatar answered Oct 29 '22 02:10

NoCarrier