Search code examples
phpunixcommand-linescreenshot

Web Page Screenshots with PHP?


I know there is not a direct way to take a screen shot of a web page with PHP. What would be the most straightforward way to accomplish this? Are there any command line tools that could do this that I might be able to execute from a PHP script (I'm thinking something that would run in a 'NIX OS (OS X and/or Linux in particular)?

Edit: Or maybe some sort of web service I could access via SOAP or REST or ...

Edit #2: I found a related question discussing the CLI option, but I'd still be open to other methods if anyone knows of anything.


Solution

  • See webkit2png for an OSX commandline program that does this.

    The page also mentions Linux alternatives.

    [edit]: wkhtml2image is the newest kid in town, and it works better then anything else i've ever used.

    [edit2]: As of 2014, PhantomJS seems to be the way to go, as it has the newest webkit version of the alternatives I know about.

    [edit3]: In 2019, Puppeteer is the way to go. Official headless chrome, always up to date.