Install extension:
(1) The following is my installation process on Linux, if Git is not installed please yum install git first
Install Casperjs
Copy Code code as follows:
CD/
git clone git://github.com/n1k0/casperjs.git
CD Casperjs
LN-SF/CASPERJS/BIN/CASPERJS/USR/LOCAL/BIN/CASPERJS//Can ignore actual execution of PHP is executed/casperjs/bin/casperjs
(2) Install PHANTOMJS, download address: http://phantomjs.org/download.html
After downloading the operation is very simple, directly unzip the good \BIN\PHANTOMJS moved to \USR\LOCAL\BIN\PHANTOMJS on it. \
The test Phantomjs--version has the result not to complain, the description installs OK
(3) Install fonts
1. First get a set of "Microsoft Ya-Black" Font library (Google a lot), including two files Msyh.ttf (ordinary), Msyhbd.ttf (bold);
2. Create a subdirectory under the/usr/share/fonts directory, such as win, which commands the following:
Copy Code code as follows:
# Mkdir/usr/share/fonts/win
3. Copy Msyh.ttf and Msyhbd.ttf to the directory, for example, the two files are placed under/root/desktop, using the command:
Copy Code code as follows:
# Cd/root/desktop
# CP Msyh.ttf msyhbd.ttf/usr/share/fonts/win/
4. Create font index information, update font caching:
Copy Code code as follows:
# Cd/usr/share/fonts/win
# Mkfontscale (if you are prompted to Mkfontscale:command not found, install it yourself # Yum install Mkfontscale)
# Mkfontdir
# Fc-cache (if prompted Fc-cache:command not found, you will need to install # Yum install fontconfig)
At this point, the font has been installed!
<?php if (isset ($_get[' url ')) {set_time_limit (0);
$url = Trim ($_get[' url ']); $filePath = MD5 ($url).
PNG ';
if (Is_file ($filePath)) {exit ($filePath); //If you do not add this sentence will be the error "Fatal: [Errno 2] No such file or directory; Did you install PHANTOMJS? ", details reference http://mengkang.net/87.html putenv (" Phantomjs_executable=/usr/local/bin/phantomjs "
);
$command = "Phantomjs phantomjs.js {$url} {$filePath}";
@exec ($command);
Exit ($filePath); }?> <! DOCTYPE html>
var page = require (' webpage '). Create ();
var args = require (' system '). Args;
var url = args[1];
var filename = args[2];
Page.open (URL, function () {
page.render (filename);
Phantom.exit ();
});
The above mentioned is the entire content of this article, I hope you can enjoy.