cutycapt(php截图工具)
1. 安裝cutycapt依賴包:
yum -y install lrzsz vim patch make gcc gcc-c++ libtool openssl openssl-devel libxml2* libxslt* popt popt-devel libXpm libXpm-devel curl-devel openldap openldap-devel m4 autoconf ncurses-devel libXi-devel libXinerama-devel libmng* libGLU-devel libICE-devel libSM-devel libXcursor-devel libXext-devel libXfixes-devel libXft-devel libXrandr-devel libXrender-devel libXt-devel libpng-devel ?libqt4-webkit libqt4-dev g++ -y
yum install svn ?注: 如果系統(tǒng)環(huán)境已經(jīng)安裝svn則不用yum安裝 否則使用svn時會報錯, 如果沒有svn 可以直接裝上
2. 下載相關(guān)軟件包
cd /usr/local/webserver
wget http://dl.atrpms.net/el5-x86_64/atrpms/testing/qt44-4.4.3-10_4.el5.x86_64.rpm
wget http://dl.atrpms.net/el5-x86_64/atrpms/testing/qt44-x11-4.4.3-10_4.el5.x86_64.rpm
wget http://dl.atrpms.net/el5-x86_64/atrpms/testing/qt44-devel-4.4.3-10_4.el5.x86_64.rpm
3.安裝:?
cd /usr/local/webserver?
rpm -ivh qt44-4.4.3-10*
rpm -ivh qt44-x11-4.4.3-10_4.el5.x86_64.rpm?
rpm -e qt-devel --nodeps --allmatches
rpm -ivh qt44-devel-4.4.3-10*
?
4. 修改環(huán)境變量
export QTDIR=/usr/lib64/qt44
export QTLIB=/usr/lib64/qt44/lib
export QTINC=/usr/lib64/qt44/include?
export LD_LIBRARY_PATH=$QTDIR/lib:$LD_LIBRARY_PATH ? ? 注意這個位置 不要替換以前的 ?只是添加
export PATH=$QTDIR/bin:$PATH:$HOME/bin ? ? ? ? ? ? ? ? 同上
5. 下載cutycapt
svn co svn://svn.code.sf.net/p/cutycapt/code/ cutycapt
mv cutycapt/CutyCapt /usr/local/webserver/CutyCapt
rm -rf cutycapt
cd /usr/local/webserver/CutyCapt
qmake
make
6. 安裝模擬 x-server 服務(wù)端
cd /usr/local/webserver
wget http://www.flexthinker.com/wp-content/uploads/2009/11/xvfb-run.sh.txt?
mv ./xvfb-run.sh.txt /usr/local/webserver/CutyCapt/xvfb-run.sh?
chmod +x /usr/local/webserver/CutyCapt/xvfb-run.sh
6. 添加中文字體
將windows 下的 C:\WINDOWS\Fonts 中的simsun.ttc ?復(fù)制到linux上 具體過程如下
?1. mkdir -p /usr/share/fonts/chinese/windows
?2. chmod -R 755 /usr/share/fonts/chinese/windows
?3. 將windows下的 simsun.ttc ?添加到 /usr/share/fonts/chinese/windows 下 ? (rz命令)
?4. cd /usr/share/fonts/chinese/windows
?5. ttmkfdir -e /usr/share/X11/fonts/encodings/encodings.dir
?6. vim /etc/fonts/fonts.conf ?添加一行 ? ?/usr/share/fonts/chinese/windows
? 24 <!-- Font directory list -->
? ? 25?
? ? 26 ? ? ? ? <dir>/usr/share/fonts</dir>
? ? 27 ? ? ? ? <dir>/usr/share/X11/fonts/Type1</dir> <dir>/usr/share/X11/fonts/OTF</dir>
? ? 28 ? ? ? ? <dir>/usr/share/fonts/chinese/windows</dir> ? ? ? ? ?添加此行,注意<dir>標(biāo)簽 ? ? ? ??
? ? 29 ? ? ? ? <dir>~/.fonts</dir>
? ? 30?
?7. /etc/init.d/xfs restart
?8.fc-list :lang=zh-cn ?查看字體有沒有添加成功
? ?NSimSun,新宋體:style=Regular
? ?SimSun,宋體:style=Regular?
? ?
? ?
? ?
7. 執(zhí)行截圖命令:
?/usr/local/webserver/CutyCapt/xvfb-run.sh --server-args="-screen 0, 1024x768x24" /usr/local/webserver/CutyCapt/CutyCapt --url=http://www.baidu.com --out=baidu.jpg ?
?
?
參考網(wǎng)址:
http://blog.sina.com.cn/s/blog_a5952cca010165cj.html
http://blog.chinaunix.net/uid-21374062-id-2983850.html
http://cutycapt.sourceforge.net/ ? ?
http://blog.csdn.net/kindy1022/article/details/7623940
如果安裝報錯 可參考下面文檔:
1. 安裝 qt ?qtwebkit
默認(rèn)yum的是qt3及qt4.2 不帶qtwebkit的,想用qtwebkit要裝更高的版本,就需要重新更改yum配置
導(dǎo)入 ATrpms’ signing key(導(dǎo)入Key),執(zhí)行
# rpm --import http://packages.atrpms.net/RPM-GPG-KEY.atrpms
舊版本rpm不能導(dǎo)入
可以用
# wget http://packages.atrpms.net/RPM-GPG-KEY.atrpms
# rpm --import RPM-GPG-KEY.atrpms
備份原來的源
# cp /etc/yum.conf /etc/yum.conf.bak
修改yum.conf
# vi /etc/yum.conf?
如果要裝qtwebkit要裝更高的版本 的在下面加上
#########################################
[atrpms]
name=Fedora Core $releasever - $basearch - ATrpms
baseurl=http://dl.atrpms.net/el$releasever-$basearch/atrpms/stable
gpgkey=http://ATrpms.net/RPM-GPG-KEY.atrpms
gpgcheck=1
=====================================================================================
如果要裝qt-47 的,改成以下, 進行網(wǎng)頁截圖的話 就改成一下這樣
##########################################
[atrpms]
name=Fedora Core $releasever - $basearch - ATrpms
baseurl=http://dl.atrpms.net/el$releasever-$basearch/atrpms/testing
gpgkey=http://ATrpms.net/RPM-GPG-KEY.atrpms
gpgcheck=1
# :wq保存退出
# yum list | grep qt47
可以發(fā)現(xiàn)atrpms里面有qt47了
安裝
# yum install qt47 qt47-webkit qt47-webkit-devel qt47-x11 qt47-sqlite
安裝gcc-c++
# yum install gcc-c++
環(huán)境變量配置
修改 /etc/profile
# vi /etc/profile
加入
export QTDIR=/usr/lib64/qt47
##export QTLIB=/usr/lib64/qt47/lib ?在真實實驗中,沒有發(fā)現(xiàn)/lib 和 /include包,所以也就不需要配置了
##export QTINC=/usr/lib64/qt47/include
##export LD_LIBRARY_PATH=$QTDIR/lib:$LD_LIBRARY_PATH
export PATH=$QTDIR/bin:$PATH
保存退出后,運行一次該文件
#source /etc/profile
輸入qmake有顯示成功配置qt
2. 安裝 cutycapt
# svn co https://cutycapt.svn.sourceforge.net/svnroot/cutycapt
# mv cutycapt/CutyCapt /usr/local/CutyCapt
# cd /usr/local/CutyCapt
# qmake
# make
出現(xiàn)以下錯誤?
/usr/lib64/qt47/libQtWebKit.so: undefined reference to `sqlite3_prepare16_v2'
/usr/lib64/qt47/libQtWebKit.so: undefined reference to `sqlite3_column_value'
collect2: ld returned 1 exit status
make: *** [CutyCapt] Error 1
解決:
#yum update sqlite
再次執(zhí)行
# make
以下表示make成功
[root@localhost CutyCapt]# make
g++ -Wl,-O1 -o CutyCapt CutyCapt.o moc_CutyCapt.o ? ?-L/usr/lib64/qt47 -lQtWebKit -lQtSvg -L/usr/lib64/qt47 -lQtGui -lQtNetwork -lQtCore -lpthread?
如出現(xiàn)
/usr/local/CutyCapt/CutyCapt: /usr/local/lib/libpng12.so.0: no version information available (required by /usr/lib64/qt47/libQtGui.so.4)
解決方法
cd /usr/local/lib
sudo mv libpng12.so.0 libpng12.so.0.backup
sudo ln -sf /usr/lib/libpng12.so.0 libpng12.so.0
這樣就OK了.
3. 安裝模擬 x-server 服務(wù)端
wget http://www.flexthinker.com/wp-content/uploads/2009/11/xvfb-run.sh.txt
mv ./xvfb-run.sh.txt /usr/local/CutyCapt/xvfb-run.sh
chmod u+x /usr/local/CutyCapt/xvfb-run.sh
4. 開始?xì)g快的截圖吧
/usr/local/CutyCapt/xvfb-run.sh --server-args="-screen 0, 1024x768x24" /usr/local/CutyCapt/CutyCapt --url=http://www.163.com --out=163.jpg
或執(zhí)行
xvfb-run --server-args="-screen 0, 1024x768x24" ./CutyCapt --url=http://www.baidu.com/ --out=localfile1.png --body-string=utf-8
出現(xiàn)-bash: xvfb-run: command not found 或 ?xauth : command not found
安裝
# yum install Xorg Xvfb xauth xorg-x11-fonts*
等一會見到生成了localfile1.png表示成功了
5. 如果看不到漢字或亂碼,需要安裝chinese字體
# yum install fonts-chinese
6. 由于截屏的是整個網(wǎng)站的頁面,只需要第一屏幕
convert -crop 1024x768+0+0 163.jpg 1632.jpg
7 . 縮小圖片
convert -resize 40%x40% 1632.jpg 1632.jpg
參考URL:
http://leyewen.blog.163.com/blog/static/25060614201212324052743/
http://blog.163.com/bqj123@126/blog/static/28351334201091955030355/
http://www.2cto.com/os/201203/122079.html
http://www.2cto.com/os/201203/122079.html
轉(zhuǎn)載于:https://blog.51cto.com/2385662/1706253
總結(jié)
以上是生活随笔為你收集整理的cutycapt(php截图工具)的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Ubuntu下编译内核
- 下一篇: L8.1 lvs+heartbeat-l