html生成图片,html生成长微博 更多功能请访问:http://www.dahuzhi.com 安装扩展: (1)下面是我在linux上的安装过程,如果没有安装git请先yuminstallgit 安装casperjs cd/ gitclonegit://github.com/n1k0/casperjs.git cdcasperjs ln-sf/casperjs/bin/casperjs/
html生成图片,html生成长微博
更多功能请访问: http://www.dahuzhi.com
安装扩展:
(1)下面是我在linux上的安装过程,如果没有安装git请先yum install git
安装casperjs
cd /
git clone git://github.com/n1k0/casperjs.git
cd casperjs
ln -sf /casperjs/bin/casperjs /usr/local/bin/casperjs //可以忽略 实际执行中php是执行 /casperjs/bin/casperjs
(2)安装phantomjs,下载地址:http://phantomjs.org/download.html
下载后操作很简单,直接把解压好的\bin\phantomjs移动到\usr\local\bin\phantomjs就可以了。\
测试phantomjs --version 有结果不报错,说明安装OK
(3)安装字体
1. 首先获得一套“微软雅黑”字体库(Google一下一大把),包含两个文件msyh.ttf(普通)、msyhbd.ttf(加粗);
2. 在/usr/share/fonts目录下建立一个子目录,例如win,命令如下:
# mkdir /usr/share/fonts/win
3. 将msyh.ttf和msyhbd.ttf复制到该目录下,例如这两个文件放在/root/Desktop下,使用命令:
# cd /root/Desktop
# cp msyh.ttf msyhbd.ttf /usr/share/fonts/win/
4. 建立字体索引信息,更新字体缓存:
# cd /usr/share/fonts/win
# mkfontscale (如果提示 mkfontscale: command not found,需自行安装 # yum install mkfontscale )
# mkfontdir
# fc-cache (如果提示 fc-cache: command not found,则需要安装# yum install fontconfig )
至此,字体已经安装完毕! CasperJS linux-ntfs PHP
<?php $www = "http://www.dahuzhi.com"; //要生成的网页地址 $name= time().'.png'; //生成的图片名 //定义js文件内容 body就是页面要生成的内容区间 也可以是页面的某个id如: #content $str = <<<ABC var casper = require('casper').create(); if(casper.cli.has(0)){ var id = casper.cli.get(0); //casper.echo(id); casper.start("@www@", function() { this.captureSelector("@name@", 'body'); }); casper.run(); }else{ casper.exit(); } ABC; $str = str_replace(array("@www@","@name@"), array($www,$name), $str); file_put_contents("test.js", $str); //如果不加这句就会报错“Fatal: [Errno 2] No such file or directory; did you install phantomjs?”,详情参考http://mengkang.net/87.html putenv("PHANTOMJS_EXECUTABLE=/usr/local/bin/phantomjs"); //调试使用下面的代码,会提示权限等各种错误,例如sh: /casperjs/bin/casperjs: Permission denied $handle = popen('/casperjs/bin/casperjs test.js '.$name.' 2>&1','r'); $read = stream_get_contents($handle); echo $read; echo '<img src="/static/imghwm/default1.png" data-src="http://'.$_SERVER['HTTP_HOST'].'/'.$name.'" class="lazy".$_SERVER['HTTP_HOST'].'/'.$name.'" alt="html生成图片,html生成长微博,网页生成图片,网页生成长微博" >'; pclose($handle);
Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article
What's New in Windows 11 KB5054979 & How to Fix Update Issues
4 weeks agoByDDD
How to fix KB5055523 fails to install in Windows 11?
3 weeks agoByDDD
InZoi: How To Apply To School And University
1 months agoByDDD
How to fix KB5055518 fails to install in Windows 10?
3 weeks agoByDDD
Where to find the Site Office Key in Atomfall
4 weeks agoByDDD

Hot Tools

WebStorm Mac version
Useful JavaScript development tools

Dreamweaver CS6
Visual web development tools

VSCode Windows 64-bit Download
A free and powerful IDE editor launched by Microsoft

PhpStorm Mac version
The latest (2018.2.1) professional PHP integrated development tool

EditPlus Chinese cracked version
Small size, syntax highlighting, does not support code prompt function
