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).
|
About me Contact me Recent posts 2010 Feb 09: FolderGlance on MacUpdate Promo 2009 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 2008 Feb 19: Spaces.. Spaces.. Spaces.. retires Feb 08: How-to: Reverse engineering the Dock to fix Spaces Jan 25: Interacting with wall-sized displays 2007 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 Aug 30: The empty shell RSS feed Links |

