This is certainly a nontrivial task. You'd need a web browser capable of operating headless and saving the image.
I've been looking into how to do this with Mozilla, it seems possible to write a XUL application which will contain a browser window, load a page, render it, then use a canvas to store it into an image and save this out as a (e.g.) PNG.
It's not easy.
There are some third party services who will do this for you though.
Mark