1

Duplicate:

website screenshots using php

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

Community
  • 1
  • 1
Kevin
  • 23,174
  • 26
  • 81
  • 111

7 Answers7

4

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

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

Alastair Stuart
  • 4,165
  • 3
  • 36
  • 33
3

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
  • 2,163
  • 3
  • 21
  • 23
2

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 left the building
  • 91,498
  • 46
  • 177
  • 222
1

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
  • 11
  • 1
1

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
  • 21,744
  • 6
  • 51
  • 55
  • There is a HTML layout engine in PHP called HTMLTOPS: http://www.tufat.com/s_html2ps_html2pdf.htm , but then you'd have to convert the resulting PostScript file to an image; that is workable but complex. – Piskvor left the building Apr 11 '11 at 09:08
1

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

Ólafur Waage
  • 68,817
  • 22
  • 142
  • 198
1

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

Peter Di Cecco
  • 1,548
  • 5
  • 15
  • 26