百分百源码网-让建站变得如此简单! 登录 注册 签到领金币!

主页 | 如何升级VIP | TAG标签

当前位置: 主页>网站教程>数据库> centos中CutyCapt安装及使用方法
分享文章到:

centos中CutyCapt安装及使用方法

发布时间:01/15 来源: 浏览: 关键词:
CutyCapt作为IECapt的兄弟,可以跨平台运行,生成的文件格式也多,SVG、PDF、 PS、 PNG、 JPEG,、TIFF,、GIF和BMP,CutyCap依赖于Qt

CutyCapt是一个截图工具

官方网站 http://cutycapt.sourceforge.net/
我主要的目的是解决用php保存网页为图片,废话不多少开始安装CutyCapt

yum install epel-release
 
#依赖安装
yum install Xvfb
yum install xorg-x11-fonts*
yum install qtwebkit-devel qt-devel
#中文字体
yum install fonts-chinese

yum install CutyCapt

#测试使用

xvfb-run --server-args="-screen 0, 1920x1080x24" CutyCapt --url=http://www.phpsong.com --out=phpsong.jpg


如果提示错误libEGL warning: DRI2: failed to open swrast (search paths /usr/lib64/dri)

解决方法

yum install mesa-dri-drivers

问题

1)截图时候有乱码
2) 执行速度慢
3)截取百度和小松博客,发现按钮上的文字没有显示,应该也是乱码导致的


PS.中文乱码问题

将windows下的中文字体上传至/usr/share/fonts目录,执行下命令fc-cache即可


测试截图

xvfb-run --server-args="-screen 0, 1920x1080x24" CutyCapt --url=http://www.phpsong.com --out=1.jpg
xvfb-run --server-args="-screen 0, 1920x1080x24" CutyCapt --url=http://www.baidu.com --out=2.jpg
xvfb-run --server-args="-screen 0, 1920x1080x24" CutyCapt --url=http://www.163.com --out=3.jpg
xvfb-run --server-args="-screen 0, 1920x1080x24" CutyCapt --url=http://www.sina.com.cn --out=4.jpg

例子

<?php
/*
网页截图功能,必须安装IE+CutyCapt
url:要截图的网页
out:图片保存路径
path:CutyCapt路径
cmd:CutyCapt执行命令
比如:http://你php路径.php?url=http://www.111cn.net
*/
$url=$_GET["url"];
$imgname=str_replace('http://','',$url);
$imgname=str_replace('https://','',$imgname);
$imgname=str_replace('.','-',$imgname);
$out = 'D:/webroot/test/'.$imgname.'.png';
$path = 'D:/webserver/CutyCapt.exe';
$cmd = "$path --url=$url --out=$out";
echo $cmd;
system($cmd);
?>

打赏

打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,你说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

百分百源码网 建议打赏1~10元,土豪随意,感谢您的阅读!

共有9人阅读,期待你的评论!发表评论
昵称: 网址: 验证码: 点击我更换图片
最新评论

本文标签

广告赞助

能出一分力是一分吧!

订阅获得更多模板

本文标签

广告赞助

订阅获得更多模板