views:

3019

answers:

8

I wonder if there is any way to convert a web page (from any given URL) into an image?

this is basically equivalent to taking a "screenshot" of the page after opening it.

There is a method to do it in firefox, using an extension; I can draw the DOM contents onto a Mozilla Canvas. But I'm wondering if there is any way to do it as a standalone application.

A: 

You could use imagemagick and write a script that fires everytime you load a webpage.

kylex
A: 

In order to take a picture of a web page, you have to render it first, so you're going to need a browser of some kind. I'll be you could do it with WebKit.

http://webkit.org/

Robert Harvey
A: 

I'm not sure if this is quite what you're looking for but I've had a lot of success using an HTML to Postscript converter html2ps to create postscript copies of web pages, which I then convert to .gif or .pngs

This doesn't produce exact screenshot quality that you'd get from a web browser and doesn't handle complicated things like flash or css all that well, but the advantage is that you can run it on the web server.

(I use it to create thumbnails of user created content, for navigation)

Colin Coghill
+1  A: 

Somebody wrote a blog post about this a few years back. There are examples in several languages, using both WebKit and Mozilla. There's also an example in Ruby.

It boils down to this: decide how wide you want your window to be; put a browser component in the window; wait until the page loads; capture the pixel buffer contents.

Jim Puls
+5  A: 

Real answers:

http://cutycapt.sourceforge.net/

http://iecapt.sourceforge.net/

http://www.websitescreenshots.com/

http://www.princexml.com/

http://khtml2png.sourceforge.net/

(Don't know of one to use Mozilla's renderer, though.)

Stobor
thanks :) btw, I found the mozilla renderer in Jim Puls' answer: http://www.hackdiary.com/2004/06/13/taking-automated-webpage-screenshots-with-embedded-mozilla/
Here Be Wolves
A: 

Not sure if this is what you want but this is what I do sometimes in a pinch when certain websites are not saving right.

I just print them to PDF and I get a PDF file of the 'print output'. There's an Microsoft XPS Document writer under my list of printers as well, but I don't use it.

Hope this helps! =)

wai
neaope.. not what I wanted, exactly.. I wanted a commandline tool to do that, and found it in the other answers, too! thanks anyway!
Here Be Wolves
+2  A: 

Using Firefox, you will need the screengrab addon.

marknt15
+4  A: 

Awesome : http://code.google.com/p/wkhtmltopdf/

PiX