In the past, we could only take screenshots of web pages in asp.net. Now I will introduce how to use a plug-in in Linux to take screenshots of web pages in PHP. I hope it will be helpful to everyone.
Server side
To realize the screenshot program, you must use the server-side program: http://code.google.com/p/wkhtmltopdf/
You can convert web pages into pdf or images. There are differences between 32-bit and 64-bit. Find a version that suits your server.
Installation
The installation process is very simple: unzip -> find a suitable path to put it down...
Execute
Command line call 1
代码如下 | 复制代码 |
/servers/app/qtwebkit/wkHtmlToImage bKjia.c0m www.bKjia.c0m.png |
The default resolution is relatively high, the picture will be very large, and it will take a certain amount of time to generate the picture.
php
The code is as follows
|
Copy code
|
||||||||||||
Detailed usage
//If the output file name is set to '-', the file data stream will be returned directly passthru('/servers/app/qtwebkit/wkHtmlToImage --width 800 --height 600 -quality 85 weibo.com -'); $fileName = self::cachePath() . '/' . self::name(); $content = ob_get_clean(); //Write image file for backup //file_put_contents($fileName, $content); //Directly output as a picture header("Content-type: image/png"); echo $content; ?>
|