wkhtmltoimage でスクリーンショットを作成しようとすると QPixmap: Cannot create a QPixmap when no GUI is being used と出て空のファイルが作成される場合の解決方法

以下の wkhtmltoimage を使用してスクリーンショットの撮影にチャレンジしているのですがエラーが発生して解決することができません。情報も海外にしかなく、海外でも解決できている人が見当たらず困っていました。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
./wkhtmltoimage http://yahoo.co.jp test.jpg
Loading page (1/2)
Rendering (2/2)                                                    
QPixmap: Cannot create a QPixmap when no GUI is being used   ] 25%
QPixmap: Cannot create a QPixmap when no GUI is being used
QPixmap: Cannot create a QPixmap when no GUI is being used
QPixmap: Cannot create a QPixmap when no GUI is being used
QPixmap: Cannot create a QPixmap when no GUI is being used
QPixmap: Cannot create a QPixmap when no GUI is being used
QPixmap: Cannot create a QPixmap when no GUI is being used
QPixmap: Cannot create a QPixmap when no GUI is being used
QPixmap: Cannot create a QPixmap when no GUI is being used
QPixmap: Cannot create a QPixmap when no GUI is being used
QPixmap: Cannot create a QPixmap when no GUI is being used
QPixmap: Cannot create a QPixmap when no GUI is being used
QPixmap: Cannot create a QPixmap when no GUI is being used
QPixmap: Cannot create a QPixmap when no GUI is being used
QPixmap: Cannot create a QPixmap when no GUI is being used
QPixmap: Cannot create a QPixmap when no GUI is being used
QPixmap: Cannot create a QPixmap when no GUI is being used
QPixmap: Cannot create a QPixmap when no GUI is being used
QPixmap: Cannot create a QPixmap when no GUI is being used
QPixmap: Cannot create a QPixmap when no GUI is being used
QPixmap: Cannot create a QPixmap when no GUI is being used
QPixmap: Cannot create a QPixmap when no GUI is being used
QPixmap: Cannot create a QPixmap when no GUI is being used
QPixmap: Cannot create a QPixmap when no GUI is being used
QPixmap: Cannot create a QPixmap when no GUI is being used
QPixmap: Cannot create a QPixmap when no GUI is being used
QPixmap: Cannot create a QPixmap when no GUI is being used
QPixmap: Cannot create a QPixmap when no GUI is being used
QPixmap: Cannot create a QPixmap when no GUI is being used
QPixmap: Cannot create a QPixmap when no GUI is being used
QPainter::begin: Paint device returned engine == 0, type: 2
QPainter::setRenderHint: Painter must be active to set rendering hints
QPainter::translate: Painter not active
QPainter::setPen: Painter not active
QPainter::setBrush: Painter not active
QPainter::setWorldTransform: Painter not active
QPainter::setOpacity: Painter not active
QPainter::setFont: Painter not active
セグメンテーション違反です

しかし下記の記事で古いバージョンのものを使用すれば上手く動くという情報がありましたので、試しに私も古いバージョンに戻してみたら普通にスクリーンショットを作成することができました。

上手く行かない場合は安定版も試してみるということの大切さを改めて実感しました。ちなみに今回の環境は CentOS 6.2 でした。海外では Ubuntu でも同じようなエラーが発生している人がいましたので、他の OS でも上手く行かなければ古いバージョンに戻してみましょう。

コメント

コメントは受け付けていません。