vartecの回答を拡張して、その使用方法も説明します...
webkit2pngをインストール
する最も簡単な方法は、おそらくgithubリポジトリのクローンを作成してセットアップを実行することです。
mkdir python-webkit2png
git clone https://github.com/adamn/python-webkit2png.git python-webkit2png
python setup.py install
これには、pythonとgitがすでにインストールされている必要があります。cygwinの場合、これによりwebkit2pngがコマンドとしてパスに追加されます。私は他の端末/OSでこれをテストしていません。
それを実行し
ますあなたが現在のディレクトリにあなたのウェブサイトを持っているとしましょう。(cssスタイルシートを使用しているhtmlファイルがありましたが、cssファイルについて考える必要はありません。)
webkit2png something.html -o something.png
オプション
webkit2png -h
は私達に知らせます:
Options:
--version show program's version number and exit
-h, --help show this help message and exit
-x WIDTH HEIGHT, --xvfb=WIDTH HEIGHT
Start an 'xvfb' instance with the given desktop size.
-g WIDTH HEIGHT, --geometry=WIDTH HEIGHT
Geometry of the virtual browser window (0 means
'autodetect') [default: (0, 0)].
-o FILE, --output=FILE
Write output to FILE instead of STDOUT.
-f FORMAT, --format=FORMAT
Output image format [default: png]
--scale=WIDTH HEIGHT Scale the image to this size
--aspect-ratio=RATIO One of 'ignore', 'keep', 'crop' or 'expand' [default:
none]
-F FEATURE, --feature=FEATURE
Enable additional Webkit features ('javascript',
'plugins')
-c COOKIE, --cookie=COOKIE
Add this cookie. Use multiple times for more cookies.
Specification is value of a Set-Cookie HTTP response
header.
-w SECONDS, --wait=SECONDS
Time to wait after loading before the screenshot is
taken [default: 0]
-t SECONDS, --timeout=SECONDS
Time before the request will be canceled [default: 0]
-W, --window Grab whole window instead of frame (may be required
for plugins)
-T, --transparent Render output on a transparent background (Be sure to
have a transparent background defined in the html)
--style=STYLE Change the Qt look and feel to STYLE (e.G. 'windows').
--encoded-url Treat URL as url-encoded
-d DISPLAY, --display=DISPLAY
Connect to X server at DISPLAY.
--debug Show debugging information.
--log=LOGFILE Select the log output file
注目すべきオプションは、幅と高さの設定です。
cygwinを使用し たトラブルシューティングwebkit2png: cannot connect to X server :0.0
で、に遭遇しました。これを修正するには(私はすでに実行していましたexport DISPLAY=0.0
)、X-Serverを起動する必要がありました。startxwin
cygwinでは、これは2番目のターミナルで実行することで実行できます。必ず最初にcygwinセットアップを介してインストールしてください。