centos中CutyCapt安裝及使用方法

來源:互聯網
上載者:User

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);
?>

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.