Skip to content

Instantly share code, notes, and snippets.

@igaiga
Created June 19, 2011 03:42
Show Gist options
  • Save igaiga/1033730 to your computer and use it in GitHub Desktop.
Save igaiga/1033730 to your computer and use it in GitHub Desktop.
wkhtmltoimage を使って変換するスクリプト
# -*- coding: utf-8 -*-
# 使い方:wkhtmltoimage と 対象のHTMLフォルダを置いて実行してください。
@option = "--width 480"
@out_ext = "png"
@out_path = "output"
def out_file_path(in_filename)
File.join(@out_path, File.dirname(in_filename), File.basename(in_filename, '.*') + '.' + @out_ext)
end
Dir.mkdir(@out_path) unless File.directory?(@out_path)
Dir.glob('**/*.html') do |filename|
out_dir = File.dirname(out_file_path(filename))
Dir.mkdir(out_dir) unless File.directory?(out_dir)
system "./wkhtmltoimage #{@option} #{filename} #{out_file_path(filename)}"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment