LoginSignup
12
15

More than 5 years have passed since last update.

サーバから画面のキャプチャを撮る(CentOS編)

Last updated at Posted at 2014-12-16

サーバから画面のキャプチャを撮る(CentOS編)

ある案件の技術調査でサーバからブラウザの画面キャプチャを取る必要があったので調査開始。

ubuntuなら結構サクサク行けそうな気がする。が、「ubuntu-desktop」とかインストールしてるのが気に食わない!

CentOSの「Desktop」とか入れたらそれとなく行きそうだけど最終目標がAWSなのでそれはなし。

とりあえず上記URLを参考に色々試してみることに。

インストール

#とりあえずxvfbとcutycaptのインストール
#yumのパッケージ名が違う・・・
[vagrant@localhost ~]$ sudo yum install xorg-x11-server-Xvfb

epelにあったけどCが両方大文字・・・
[vagrant@localhost ~]$ sudo yum install http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
[vagrant@localhost ~]$ sudo yum --enablerepo=epel install CutyCapt

なぜ両方ともパッケージ名が違うのか・・・orz

情報がなさ過ぎて見つけるのに一苦労・・・

試行1

[vagrant@localhost ~]$ xvfb-run --server-args="-screen 0, 1024x768x24" \
CutyCapt --url=http://yahoo.com/ --out=hoge.png
process 2170: D-Bus library appears to be incorrectly set up; failed to read machine uuid: Failed to open "/var/lib/dbus/machine-id": そのようなファイルやディレクトリはありません
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 166:  2170 アボートしましたDISPLAY=:$SERVERNUM XAUTHORITY=$AUTHFILE "$@" 2>&1

エラーが出たので修正

[root@localhost ~]# dbus-uuidgen > /var/lib/dbus/machine-id

試行2

[vagrant@localhost ~]$ xvfb-run --server-args="-screen 0, 1024x768x24" \
> CutyCapt --url=http://yahoo.com/ --out=hoge.png
QFont::setPixelSize: Pixel size <= 0 (-1)
QFont::setPixelSize: Pixel size <= 0 (-1)
QFont::setPixelSize: Pixel size <= 0 (-1)
QFont::setPixelSize: Pixel size <= 0 (-1)
QFont::setPixelSize: Pixel size <= 0 (-1)
QFont::setPixelSize: Pixel size <= 0 (-1)
QFont::setPixelSize: Pixel size <= 0 (-1)
QFont::setPixelSize: Pixel size <= 0 (-1)
QFont::setPixelSize: Pixel size <= 0 (-1)

画像はできた!けど文字が表示されてない・・・

フォントをインストール

#探す!
[vagrant@localhost ~]$ sudo yum search japanese
#とりあえず適当に
[vagrant@localhost ~]$ sudo yum install vlgothic-fonts

試行3

[vagrant@localhost ~]$ xvfb-run --server-args="-screen 0, 1024x768x24" \
CutyCapt --url=http://yahoo.com/ --out=hoge.png
#できた!
[vagrant@localhost ~]$ xvfb-run --server-args="-screen 0, 1024x768x24" \
CutyCapt --url=http://www.yahoo.co.jp/ --out=hoge.png
#日本語も文字化けてない!

まとめ

というわけで、サーバからキャプチャは割とすんなり撮れる!

AWSですんなりいかなかったは別の話・・・

12
15
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
12
15