Screenshot of current page using PHP

后端 未结 7 1812
时光取名叫无心
时光取名叫无心 2020-12-12 04:45

Duplicate:

website screenshots using php

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

相关标签:
7条回答
  • 2020-12-12 04:45

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

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

    0 讨论(0)
  • 2020-12-12 04:45

    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.

    0 讨论(0)
  • 2020-12-12 04:56

    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");
      }
    ?>
    
    0 讨论(0)
  • 2020-12-12 05:03

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

    0 讨论(0)
  • 2020-12-12 05:07

    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.
    0 讨论(0)
  • 2020-12-12 05:09

    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.

    0 讨论(0)
提交回复
热议问题