Ampelofilosofies

homeaboutrss
The mind is like a parachute. If it doesn't open, you're meat.

Capturing web pages as images

25 Jun 2010

I have been looking for a way to capture web pages as images from the command line and/or programmatically.

There doesn’t seem to be the “easy” way so this merits a note to self.

The command-line-utility-you-can-wrap-in-a-system()-call way

There are a few command line utilities, but they are not fully cross-platform:

CutyCapt works on Windows and Linux. It uses the WebKit engine.

IECapt from the same guy offering CutyCapt uses IE and obviously only runs on Windows.

webkit2png will fill your OS X needs

The write-some-code-in-Ruby way

Get selenium-rc,install the proxy and use the page snapshot functionality. If only you didn’t have to use the damn selenium proxy this would have been perfect.

There is Selenium gem which bundles selenium-rc and adds a CLI wrapper to start and stop the proxy server but it hasn’t been updated since July 2008 which makes the bundled selenium-rc version suspect.

The start/stop functionality is also implemented as blocking calls which a bit of a bother.

The wrapper for the server is essentially a system() call to java so it is relatively simple to grab the latest selenium-rc code and just use the code to programmatically start/stop the proxy server - still, not the easy out-of-the-box solution I would like.

Anyone else have any suggestions?