Anton Kihlström Anton Kihlström - 6 months ago 52
PHP Question

How to screenshot a webpage in php?

I am currently making a website where simply I want users to be able to screenshot a webpage and then download the image.
So what I need help with is how to screenshot a webpage using php and then save the image on my server.

I have read a few other topics about how to screenshot a page but I can't get it to work.

I am using a linux server (Debian 7.0)

Thanks for help :D

Answer

You can use grabz.it


Take Website Screenshots with PHP

  1. Get your free Application Key and Secret.
  2. Download the free PHP Demo and Library and try it out.

Then use it like this:

include("GrabzItClient.class.php");
$grabzIt = new GrabzItClient("APPLICATION KEY", "APPLICATION SECRET");
$grabzIt->SetImageOptions("http://www.google.com"); 
$grabzIt->SaveTo("google.jpg");

If you don't want to depend on 3rd parties, you can use phantomjs, i.e.:

phantomjs responsive-screenshot.js http://google.com

Notes:

1- Download responsive-screenshot.js. Check the source code for available options.

2- You can install phantomjs by cloning the github repo:

git clone https://github.com/ariya/phantomjs.git
Comments