Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to take a screenshot of a loaded webpage using php? [duplicate]

I need to take screenshots of few web pages and save them in a folder using php.

I want to do this using a php script, is there a way I can render those webpages and take screenshot of a particular area after the website is fully loadedd? - I'm using windows.

I tried using wkhtmltoimage but it takes low quality screenshots and also it takes the screenshot before the whole page is loaded, so some images of the webpage are not appearing in the screenshot, is there a way to do this using php?

Please help php specialists. Thank you

like image 326
new_one Avatar asked Nov 20 '16 16:11

new_one


People also ask

Is there a way to take a screenshot of an entire webpage?

Click the three-dot icon from the top-right corner and select Run command. Also, you can press Ctrl+Shift+P on Windows or Command+Shift+P on Mac. Type screenshot into the search box. Select Capture full-size screenshot.

How do I take a screenshot of a protected Web page?

Android. The universally acknowledged screenshot shortcut that usually works across Android versions, manufacturers, and handsets is Power+Volume Down.

How do I take a screenshot of a whole web page in Windows?

Open the webpage you want to capture, then press and hold “Ctrl” + “Alt.” Then, press the “Prtsc” key. Left-click on the corner of the red highlighted box and drag to select the screenshot area.


1 Answers

PHP runs on server side, so to be able to take screenshots you need something to render HTML (a browser-like script) and generate a image of it. This script will do that (wkhtmltoimage too):

HTML2PS: http://freecode.com/projects/html2ps_php

But I still think the best solution will be using javascript. Of course, only the client will have access to the screenshots, and maybe you can upload the image to the server. A client browser is better than any kind of server script.

If that is the case, I would suggest using HTML2CANVAS:

HTML2CANVAS: http://html2canvas.hertzen.com/

The best server solution will be a linux distribution with a google chrome installation and a local script to take screenshots. That is the only way to get accurate screenshots of a web page that may contain javacript/HTML5/animations and other difficult to render stuff.

like image 115
Adriano Moutinho Avatar answered Oct 21 '22 10:10

Adriano Moutinho