One problem I've been toying with off and on is a service that requires my server to produce a screenshot of a webpage at a given url. The problem is that I don't have any idea how I would accomplish this. I mostly use a LAMP software stack, so answers that were given with that in mind would be the most helpful. Again the basic requirements are: Given a url, the server needs to produce an image file of the rendered web page at that url. Thanks in advance!
-
1don't worry traumaPony, my web service has nothing to do with pop up images that hover over links while you're trying to read an article :) – Jurassic_C Sep 23 '08 at 04:37
8 Answers
You might also want to take a look at webkit, it's known for being easier to embed (used by Adobe for AIR, by Google for Chrome, by Apple for the iPhone...) then other rendering engines. This might take a little more work to setup, but it would be a lot more stable than some hack that launched a webbrowser and took a screenshot.

- 18,877
- 17
- 76
- 99
-
3Nowadays there is available [PhantomJS](http://www.phantomjs.org/), a headless WebKit. – jholster Mar 04 '12 at 11:04
-
@jholster Thanks for this comment! PhantomJS looks exactly like what I was looking for! – ahans May 31 '12 at 16:18
IF your server is a Mac, then I recommend webkit2png, which is a short python program that leverages WebKit's Objective-C API to render an URL. Personally, I use it in combination with WWW::Mechanize to walk my development site and make screenshots of every page -- useful for testing functionality, showing clients and keeping screenshots up-to-date. The resulting screenshot is perfect, but sometimes very tall for long, scrolling pages.
IF your server has a non-bare-bones Linux distro with KDE installed, then you might try khtml2png. I have not tried that myself, but saw it mentioned on the webkit2png page.

- 8,905
- 2
- 35
- 73
-
Somehow I don't think there are that many Mac servers out there, but khtml2png looks good too (if not as polished) – davr Sep 29 '08 at 15:05
You actually need to have the server launch the web browser in question and take a screenshot of the application with the appropriate libraries. Apache will not render the page for you so you have to have software that will.

- 19,053
- 13
- 51
- 67
-
right. A couple of ideas that I had were to actually automatically collect a screenshot from the desktop environment, or somehow use the gecko engine to build a rendered version of the page that I could build an image from. Hmm.... – Jurassic_C Sep 23 '08 at 04:35
Yes, that is what is needed. I do this in asp.net, and I actually create a WebBrowser object that is avaialable in the .Net framework class libraries to generate the screenshot.

- 11,310
- 11
- 51
- 70
I use the http://webthumb.bluga.net service for thumbnail generation. Robust, powerful, easy to use, and very reasonable rates. I have a high traffic production website using this service and it works very well. Given the difficulty of creating a robust web screenshot service, it's nice to have someone else do the hard work.

- 2,100
- 2
- 21
- 29
A non-free solution for Java is WebRenderer. Interesting feature: it can emulate Safari, IE or Firefox browsers when rendering. They have a desktop version and a headless server version. Also they have example code showing how to render a screenshot image of a webpage.

- 2,100
- 2
- 21
- 29
virtual framebuffer X server
I would rather recommend XVFB (virtual framebuffer X server) is the best solution for taking screenshots of a headless server. Virtual framebuffer X server xvfb provides an X server that can run on machines with no display hardware and no physical input devices. I am using that on my server for testing URLs and taking its screenshot. We are using Ubuntu & XVFB + FIREFOX. It is working fine. Modify according to your needs.Take a look on these articles. It might be use full for you.
http://www.semicomplete.com/blog/geekery/xvfb-firefox.html

- 2,602
- 6
- 32
- 44