CentOS6 with CutyCapt

CentOS6 with CutyCapt

vi /etc/yum.repos.d/atrpms.repo
[atrpms]
name=CentOS $releasever – $basearch – ATrpms
baseurl=http://dl.atrpms.net/el$releasever-$basearch/atrpms/stable
gpgkey=http://ATrpms.net/RPM-GPG-KEY.atrpms
gpgcheck=1
enabled=1

[atrpms-testing]
name=CentOS $releasever – $basearch – ATrpms testing
baseurl=http://dl.atrpms.net/el$releasever-$basearch/atrpms/testing
gpgkey=http://ATrpms.net/RPM-GPG-KEY.atrpms
gpgcheck=1
enabled=1

yum install qt47 qt47-devel qt47-webkit qt47-webkit-devel
yum -y install subversion
yum -y install gcc+ gcc-c++
svn co https://cutycapt.svn.sourceforge.net/svnroot/cutycapt
vi /etc/profile
export QTDIR=/usr/lib64/qt47
export QTLIB=/usr/lib64/qt47/lib
export QTINC=/usr/lib64/qt47/include
export LD_LIBRARY_PATH=$QTDIR/lib:$LD_LIBRARY_PATH
export PATH=$QTDIR/bin:$PATH

mv cutycapt/CutyCapt /usr/local/cutycapt
cd /usr/local/cutycapt
qmake
make

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
yum install xorg-x11-server-Xvfb
yum install cjkuni-ukai-fonts cjkuni-uming-fonts -y

CentOS 安裝cutycapt 二

CentOS 安裝cutycapt 二

CutyCapt作爲IECapt的兄弟,可以跨平臺運行,生成的文件格式也多,SVG、PDF、 PS、 PNG、 JPEG,、TIFF,、GIF和BMP,CutyCap依賴于Qt。
一,先安裝Qt47
增加qt47的下載源
vi /etc/yum.repos.d/atrpms.repo
[atrpms]
name=CentOS $releasever – $basearch – ATrpms
baseurl=http://dl.atrpms.net/el$releasever-$basearch/atrpms/stable
gpgkey=http://ATrpms.net/RPM-GPG-KEY.atrpms
gpgcheck=1
enabled=1

[atrpms-testing]
name=CentOS $releasever – $basearch – ATrpms testing
baseurl=http://dl.atrpms.net/el$releasever-$basearch/atrpms/testing
gpgkey=http://ATrpms.net/RPM-GPG-KEY.atrpms
gpgcheck=1
enabled=1
#yum update
yum install qt47
yum install qt47-devel
yum install qt47-webkit
yum install qt47-webkit-devel
可能的錯誤:
warning: qt44-x11-4.4.3-10_4.el5.x86_64.rpm: Header V4 DSA signature: NOKEY, key ID 66534c2b
解决:
yum -y installqt-devel*
可能的錯誤:某些衝突conflict
qt47-x11 conflicts with qt-x11
qt47-x11 conflicts with qt-x11
解决:通過yum remove 卸載衝突的內容
yum remove qt-devel
yum remove qt-x11
二,安裝 CutyCapt
下載代碼,這裏需要用到SVN,如果沒有安裝,可以使用命令安裝:
#yum install subversion
svn co https://cutycapt.svn.sourceforge.net/svnroot/cutycapt
mv cutycapt/CutyCapt /usr/local/cutycapt
cd /usr/local/cutycapt
qmake
可能會出現的錯誤:
-bash: qmake: command not found
解决:
qmake-qt47
make
此處可能會報錯:
make: *** [CutyCapt] Error 1
解决:
yum update sqlite #如果是6.0,默認就是3.6
再次執行make即可!
三、下載和安裝X-Server
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
出現錯誤提示:CutyCapt: cannot connect to X server :99
可以使用命令安裝:
yum install xorg-x11-server-Xvfb
四,安裝中文包
yum install fonts-chinese
五,運行 CutyCapt進行截圖:執行以下命令,如果沒有錯誤,就會在當前目錄下面保存截圖。
/usr/local/cutycapt/xvfb-run.sh –server-args=”-screen 0, 1024x768x24″ /usr/local/cutycapt/CutyCapt –url=http://www.163.com –out=163.jpg
六 ,其他一些相關問題
Q:出現-bash: xvfb-run: command not found 或 xauth : command not found
安裝 yum install Xorg xauth xorg-x11-fonts*(Xorg,xauth,xorg-x11-fonts* 這是三個不同的工具,每個都需要單獨運行yum install來安裝)
Q:錯誤提示:”mktemp: too few X’s in template `Xauthority’.”
找到 AUTHFILE=$(mktemp -p “$XVFB_RUN_TMPDIR” Xauthority)
修改爲:AUTHFILE=$(mktemp -p “$XVFB_RUN_TMPDIR” Xauthority.XXXXXXXX)
Q:錯誤提示:CutyCapt: cannot connect to X server :99
確認server-args參數是否正確,修改xvfb-run.sh脚本中SERVERNUM=99 改爲SERVERNUM=0
Q:截出來的圖片沒有中文字,需要安裝中文字體
yum install cjkuni-ukai-fonts cjkuni-uming-fonts -y
Q:由于截屏的是整個網站的頁面,只需要第一屏幕
convert -crop 1024×768+0+0 163.jpg 1632.jpg
Q:縮小圖片
convert -resize 40%x40% 1632.jpg 1632.jpg
Q:CutyCapt: cannot connect to X server
網上很多都是要在裝個xvfb-run.sh的,其它不用這麽麻煩
echo “export DISPLAY=’:1.0′” >> /etc/profile
source /etc/profile
vncserver
# ./CutyCapt –help
不過每次都輸入export LIBXCB_ALLOW_SLOPPY_LOCK=1有點麻煩,大神給了個解决方法!
cat > run
vi run
輸入
export LIBXCB_ALLOW_SLOPPY_LOCK=1
../../xvfb-run.sh ./CutyCapt –url=$1 –out=$2 –body-string=$3
保存退出
chmod +x ./run
./run http://www.baidu.com test.jpg, utf-8
依次輸入 $1 http://www.baidu.com $2 圖片名 $3字體
Q:環境變量配置
# vi /etc/profile 未尾加入以下代碼
export QTDIR=/usr/lib/qt44
export QTLIB=/usr/lib/qt44/lib
export QTINC=/usr/lib/qt44/include
export LD_LIBRARY_PATH=$QTDIR/lib:$LD_LIBRARY_PATH
export PATH=$QTDIR/bin:$PATH
# source /etc/profile