Taking screenshot of a website using PHP on windows os

I have been trying to figure out a way using I could take a screenshot of any provided URL using PHP.
Finally I could find out a way of doing it and that is by using the COM object on windows os.

I have written a class for taking the screenshot.
For using it, all you need to do is:

Download the class file from here.
Rename it and remove the .txt entention
Include the class file in the required script.
And then,
Create a new object:

$s = new akjScreenshot(”http://amanjain.com”);

Resize if required:

$s->toWidth(100);
$s->toHeight(100);

Save:

$s->save(”screen.jpg”);

You can also save it in different formats like:

$s->save(”screen.png”, “png”);
$s->save(”screen.gif”, “gif”);

I hope it helps :) Please leave a comment if you find it useful.

Check out PHPCamp.net a article sharing website relevant to our own PHP community

2 Responses to “Taking screenshot of a website using PHP on windows os”

Serban (November 12th, 2009 at 11:15 pm)

Hello. Nice resource, i needed this for a project of mine on Windows. Thanks!

Aman (November 13th, 2009 at 1:43 am)

Welcome :)

Leave your response!

Be nice. Keep it clean. Stay on topic. No spam.