php pdf首页截图,安装wkhtmltopdf让php在linux环境下给网站截屏

http://wkhtmltopdf.org/obsolete-downloads.html

新版本依赖包比较多,我是centos5.8系统,这里使用64位老版本,同时它还用windows下的版本

wget http://download.gna.org/wkhtmltopdf/obsolete/linux/wkhtmltoimage-0.10.0_rc2-static-amd64.tar.bz2

tar -jxvf wkhtmltoimage-0.10.0_rc2-static-amd64.tar.bz2

解压后就可使用

./wkhtmltoimage-amd64 –help

Name:

wkhtmltoimage 0.10.0 rc2

Synopsis:

wkhtmltoimage [OPTIONS]…

Description:

Converts an HTML page into an image,

General Options:

–crop-h Set height for croping

–crop-w Set width for croping

–crop-x Set x coordinate for croping

–crop-y Set y coordinate for croping

-H, –extended-help Display more extensive help, detailing

less common command switches

-f, –format Output file format (default is jpg)

–height Set screen height (default is calculated

from page content) (default 0)

-h, –help Display help

–quality Output image quality (between 0 and 100)

(default 94)

-V, –version Output version information an exit

–width Set screen width (default is 1024)

(default 1024)

Contact:

If you experience bugs or want to request new features please visit

, if you have any problems

or comments please feel free to contact me:

./wkhtmltoimage-amd64 http://www.baidu.com baidu.jpg

Loading page (1/2)

Rendering (2/2)

Done

截一张1024*1024 质量为35的jpg图片

./wkhtmltoimage-amd64 –crop-h 1024 –crop-w 1024 –quality 35 http://blog.c1gstudio.com c1g.jpg

d6e59e7aa5c51e2660c8af18e054f40f.png

和php结合

cp wkhtmltoimage-amd64 /opt/toolkits/

chown www:website /opt/toolkits/wkhtmltoimage-adm64

chmod 550 /opt/toolkits/wkhtmltoimage-adm64

vi /opt/php/etc/php.ini

open_basedir = “/opt/htdocs:/tmp/session:/tmp/upload:/opt/php/PEAR:/opt/php/lib/php:/opt/toolkits/”

重启phpfpm

/opt/php/sbin/php-fpm restart

vi test.php

exec(/opt/toolkits/wkhtmltoimage-amd64 --crop-h 1024 --crop-w 1024 --quality 35 http://blog.c1gstudio.com c1g.jpg);

?>

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值