I recently had the need for a simple tool to render an entire web page and store it to an image file (like a png or a jpeg). I knew that doing this should be very simple using Cocoa, and indeed it was. I have made the code and executable (Mac OS X 10.5 or later, Universal) available for download here. The code is released under the BSD license. The only thing to watch out for is that you need to be logged in to a window server session on Mac OS X in order to use the tool, as it needs a connection to the window server in order to run. Behind the scenes, www2image uses WebKit to render the URL you give it to a WebView, which is then stored to a JPEG.
Usage of the tool is very simple. You can either build it from source, or use the pre-built version (in www2image/build/Release/):
[#] cd path/to/www2image/build/Release [#] ./www2image -u <URL> [-o output file name]
For instance, to create an image of this page and store it as example.jpg:
[#] ./www2image -u http://www.scsc.no/blog/ -o example.jpg
Wait for a few seconds while the tool executes, and voila, you'll end up with a picture similar to the one shown below (note that I've resized and cropped this image, since the actual version would have a height of about 4000 pixels):
This site rendered using www2image (note that the actual version renders the entire page in full resolution, not just the top part).
Comments by Disqus
Spaces.. Spaces.. Spaces.. (Retired)
Jul 28: Running iTunes in a debugger (gdb)
Jul 25: The /Volumes/MobileBackups directory
Jul 20: FolderGlance 3.0.1 supports Lion
Mar 03: Quick tip: Speeding up Xcode compilations
Mar 02: FolderGlance 3.0
Jan 07: Making Universal Back Button work on 10.6.5 and later
Sep 03: Creating pthreads in C++ using pointers to member functions
May 31: Quickly open URLs in Terminal
May 31: Snow Leopard and automatically submitted Crash Reports
May 27: Universal Back Button released for Mac OS X
May 22: The 22 Megapixel Laptop
Feb 09: FolderGlance on MacUpdate Promo
Sep 28: FolderGlance 2.5.3 is out
Sep 21: FolderGlance 2.5.1 adds features and fixes bugs
Sep 16: FolderGlance 2.5 released!
Sep 10: Intriguing: Snow Leopard ships with the iPhone's multi-touch API built-in
Sep 03: FolderGlance and Snow Leopard
Mar 15: Fixing Keynote '08 and '09 to work with the Scripting Bridge
Feb 26: A website in an image
Feb 09: Display wall multi-touch
Feb 19: Spaces.. Spaces.. Spaces.. retires
Feb 08: How-to: Reverse engineering the Dock to fix Spaces
Jan 25: Interacting with wall-sized displays
Dec 20: Interesting Finder bug
Dec 06: Developing applications for the iPod touch (and the iPhone)
Nov 15: Spaces.. Spaces.. Spaces.. and 10.5.1
Nov 15: Thread creation using pthread_create() on Leopard
Nov 13: Spaces.. Spaces.. Spaces..
Nov 07: FolderGlance, Leopard and the More... menu
Nov 06: FolderGlance and Screen Sieve now also on Leopard!
Sep 16: Mysterious window server hangs