Created
June 19, 2011 03:42
-
-
Save igaiga/1033730 to your computer and use it in GitHub Desktop.
wkhtmltoimage を使って変換するスクリプト
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- 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