Created
August 9, 2012 16:51
-
-
Save youpy/3305827 to your computer and use it in GitHub Desktop.
generate image for TEE PARTY
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 -*- | |
require 'shellwords' | |
require 'nokogiri' | |
require 'open-uri' | |
def main | |
unicode, font_path, file = ARGV | |
info = info(unicode) | |
abort unless info.name | |
# brew instal graphicsmagick | |
system(*%W(gm convert | |
-debug annotate | |
-trim | |
-font #{e(font_path)} | |
-background white | |
-size 2924x3990 | |
-resize 2924x3990 | |
-gravity center | |
-extent 2924x3990 | |
label:#{[unicode.to_i(16)].pack("U")} | |
-fill black | |
-transparent white | |
#{e(file)})) | |
end | |
def e(str) | |
Shellwords.escape(str) | |
end | |
def info(unicode) | |
doc = Nokogiri::HTML(open('http://www.fileformat.info/info/unicode/char/%s/index.htm' % unicode.downcase)) | |
Struct.new(:name, :code).new(*doc.title.scan(/'(.+)' \((U\+[\dA-F]+)/)[0]) | |
end | |
main |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment