It is extremely nontrivial. In practice, you need to create an instance of a browser which will render into an offscreen area, then capture that. It's nontrivial because browsers can't easily be made to do this, and there are a lot of security/reliability issues. It also uses a lot of server-side resources.
If you have a real willingness to do it and adequate development resource, hosting resource etc to support a (fairly) clever solution, I have a framework I developed which can take screenshots of pages.
It's not in PHP however, instead PHP talks to a Mozilla-based application via sockets which runs an embedded mozilla browser.
Mark