Umi and Satomi


Screen-capture with wkhtmltoimage(wkhtmltopdf) onLinux

In many cases, phantom.js is used to get screen capture. But wkhtmltoimage can be alternative.


$ sudo yum install -y openssl libX11 libXext
$ cd /usr/local/src
$ wget

$ sudo rpm -ivh wkhtmltox-
error: Failed dependencies:
    xorg-x11-fonts-Type1 is needed by wkhtmltox-1:
    xorg-x11-fonts-75dpi is needed by wkhtmltox-1:

Install dependencies

$ sudo rpm -ivh

$ sudo rpm -ivh

$ sudo rpm -ivh

$ sudo rpm -ivh wkhtmltox-

Japanese Font

Install IPA font

# set font files at user home directory 
$ mkdir ~/.fonts
$ cp ~/.fonts
$ cd ~/.fonts 
$ unzip 
# clear font cache
$ fc-cache -fv
# confirm installed font
$ fc-list

if something doesn't go well....

$ sudo cp ~/.fonts/*.ttf /usr/share/fonts/


$ wkhtmltoimage hoge.jpg


if you want to edit captured image, try to use IMGKit.

but lots of error has occurred by IMGKit, so I think Phantom.js is better solution than this.

Batch Script

basic script to get screenshot and save to /tmp/screenshot/hoge.jpg

# encoding: utf-8
namespace :screenshot do
  desc "get screenshot from official_url and save tmp/screenshots/"
  task :get => :environment do

    quality       = 100
    aspect_width  = 4
    aspect_height = 3 # height : width = 4 : 3
    width         = 1200
    height        = width * 3 /4

    output_dir = "tmp/screenshots/"

    items.each do |item|
      output_file = "#{}.jpg"
      file_path = output_dir + output_file
      command = "wkhtmltoimage --quality #{quality} --width #{width} --height #{height} #{url} #{file_path}"


process of getting screenshot sometimes stop by some reasons. network trouble, batch-server-spec, js, css... so try many time to get image completely.