tags:

views:

319

answers:

7

Duplicate:

website screenshots using php

Is it possible to take a screenshot of the current page using PHP?

+3  A: 

No*

  • PHP runs on the web server not on the client where the browser is and cannot control the browser or other portions of the operating system remotely.
Dean Smith
+5  A: 

PHP doesn't render the page, the browser does.

Here is a list of tools that let you do what you're after.

coob
+1  A: 

In theory, you could write a HTML layout engine as a PHP extension, and use that... But, no, there's nothing already in PHP that'll do what you want.

You could use a command-line utility like this and call it from PHP.

Jeff
+2  A: 

If you're on windows. There's imagegrabscreen()

Ólafur Waage
+1  A: 

Here's a neat Firefox add-on: Screengrab!

Peter Di Cecco
+1  A: 

You could install webkit2png on your server and then execute webkit2png http://yourpage.example.com from your PHP script. That will give you a screenshot the way Webkit renders the page. For installing on Linux, see this.

Piskvor
A: 

If you are using Windows platform, you can install ACA WebThumb ActiveX: http://www.acasystems.com/en/web-thumb-activex

A simply demo:


<?php
  // PHP html to image.
  // This script shows how to convert the google.com homepage to a PNG image file.
  $WebThumb_Maker = new COM('ACAWebThumb.ThumbMaker')
    or die("Start ACAWebThumb.ThumbMakerfailed");

  $WebThumb_Maker->SetURL("http://www.google.com"); 
  if ( 0 == $WebThumb_Maker->StartSnap() )
  {
    // Tanke snapshot successful, call SetImageFile() to save the image as a PNG file.
    echo "Take snapshot successful." ;
    $WebThumb_Maker->SaveImage("google.png");
  }
?>
Alex.S