views:

1719

answers:

6

Just wondering if it's possible to screen grab a page you are viewing with a PHP script or javascript? For example, load up a page in an iframe and then save that view as a JPEG?

I'm sure it's possible somehow, but are there any known implementations/libraries that help out?

+2  A: 

There is a python tool called Webkit2png, hope it helps. But in PHP, i don't believe its possible

Ólafur Waage
+4  A: 

Nope, sorry, it is impossible with Javascript and definitely impossible with a server-side language like PHP. (Edit: I mean it's impossible to take a screenshot of the user's view of the page.)

It depends on what you want to do this for, but you might want to find a script or program that runs server-side and renders the webpage there. But if you really want to take the screenshot of the user's view of the page, it's pretty much impossible.

yjerem
+1  A: 

You can't do it in JS but you could do something similiar server side if you know the url of the page you want to convert to an image.

Tools like khtml2png could be called from php to render the page.

Twelve47
A: 

Thanks for the help guys. I did find this interesting resource:

http://www.zubrag.com/scripts/website-thumbnail-generator.php

It's not PHP specific by any means, just an example of running an EXE script that is called by PHP. Needs a windows server I believe though.

AndreLiem
+1  A: 

Possible with the GD2 extension and some knowledge of the internals you are capturing - read here for an example.

Eran Galperin
A: 

there was a similar question

Gene T