centos6 截图 CutyCapt

install cutycapt

安装完后会有/usr/bin/CutyCapt和/usr/bin/xvfb-run

# yum install -y epel-release
# yum install -y CutyCapt
example
$ xvfb-run --server-args="-screen 0, 1024x768x24" ./CutyCapt --url='http://baidu.com' --out=/tmp/baidu.png
报错处理
$ /usr/bin/xvfb-run --server-args="-screen 0, 1024x768x24" /usr/bin/CutyCapt --url='http://baidu.com' --out=/tmp/a.png
process 10606: D-Bus library appears to be incorrectly set up; failed to read machine uuid: Failed to open "/var/lib/dbus/machine-id": No such file or directory
See the manual page for dbus-uuidgen to correct this issue.
  D-Bus not built with -rdynamic so unable to print a backtrace
/usr/bin/xvfb-run: line 181: 10606 Aborted                 DISPLAY=:$SERVERNUM XAUTHORITY=$AUTHFILE "$@" 2>&1

使用命令生成machine-id即可

dbus-uuidgen > /var/lib/dbus/machine-id
常见问题

xvfb相关问题汇总
CutyCapt官网
dbus生成machine-id

shell示例
#!/bin/sh
. ~/.bash_profile
function encodeurl()
{
    encoded_str=`echo "$*" | awk 'BEGIN {
        split ("1 2 3 4 5 6 7 8 9 A B C D E F", hextab, " ")
        hextab [0] = 0
        for (i=1; i<=255; ++i) {
            ord [ sprintf ("%c", i) "" ] = i + 0
        }
    }
    {
        encoded = ""
        for (i=1; i<=length($0); ++i) {
            c = substr ($0, i, 1)
            if ( c ~ /[a-zA-Z0-9.-]/ ) {
                encoded = encoded c             # safe character
            } else if ( c == " " ) {
                encoded = encoded "+"   # special handling
            } else {
                # unsafe character, encode it as a two-digit hex-number
                lo = ord [c] % 16
                hi = int (ord [c] / 16);
                encoded = encoded "%" hextab [hi] hextab [lo]
            }
        }
        print encoded
    }' 2>/dev/null`
}

#-----------main-----------------
if [ $# -ne 3 ]; then
    echo "Usage: $0 <vod_url> v/h job_id vs_no"
    exit 1
fi

cap_bin=/usr/bin/CutyCapt
cap_dir=/ebs_data/opt/typhoonae/var/temp/web2png
job=$3
vs_no=$4
delay_tm=1000
if [ $2 = "v" ]; then
sc_width=720
sc_height=1280
else
sc_width=1280
sc_height=720
fi
if [ -n "$job" ]; then
    echo -n "..."
else
    job="1101"
fi

encodeurl "$1"
#vod_url="${encoded_str}"
vod_url=$1
echo "${cap_bin} --url='${vod_url}' --min-width=${sc_width} --min-height=${sc_height} --delay=${delay_tm} --max-wait=5000 --out=${cap_dir}/snap_screen_${job}.png"
/usr/bin/xvfb-run --server-args="-screen 0, 1024x768x24" $cap_bin --url="${vod_url}" --min-width=${sc_width} --min-height=${sc_height} --delay=${delay_tm} --max-wait=5000 --out=${cap_dir}/snap_screen_${job}.png
echo "Result: ${cap_dir}/snap_screen_${job}.png"

转载于:https://blog.51cto.com/chaoyuezhangsan/2073954

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值