In between midnight summer nights and dark winter days

A website in an image Wed, Feb 25 2009 21:02

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).



Previous: Display wall multi-touch Next: Fixing Keynote '08 and '09 to work with the Scripting Bridge

About me
My name is Daniel Stødle. I live in Tromsø, Norway, at 69.66° North. By day, I work as a researcher at the Northern Research Institute in Norway; by night, I run my company SCSC. I do most of my development on and for Mac OS X. My research is geared towards interaction with and visualization of geospatial data. Read more on my personal page.

Software

Contact me
E-mail: daniel@scsc.no

Recent posts


2011
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

2010
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

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

Archive
2007
2008
2009
2010
2011

RSS feed
RSS

Links
SCSC
Blog frontpage