Created
May 8, 2016 07:02
-
-
Save yalab/92d5901a8dea762eeada18e692f6ce84 to your computer and use it in GitHub Desktop.
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
| GC.disable | |
| before = `ps -o rss= -p #{Process.pid}`.to_i | |
| require 'bundler/setup' | |
| require 'mini_magick' | |
| OUTPUT = "output.png" | |
| MATERIAL = "material.png" | |
| FONT_PATH = '/Library/Fonts/Osaka.ttf' | |
| BACKGROUND_COLOR = "#000000" | |
| labels = [ | |
| {label: "山田 太郎", pos: "+110+165", size: "14"}, | |
| {label: "5 4 1", pos: "+93+183", size: "20"}, | |
| {label: "0 0 4 4", pos: "+154+183", size: "20"}, | |
| {label: "大阪市 中央区", pos: "+100+226", size: "14"}, | |
| {label: "伏見町 4-4-9", pos: "+100+247", size: '14'}, | |
| {label: "06", pos: '+110+207', size: '14'}, | |
| {label: "7878", pos: "+150+207", size: '14'}, | |
| {label: "6838", pos: '+180+207', size: '14'}, | |
| {label: "吉田 篤", pos: '+110+267', size: '14'}, | |
| ] | |
| MiniMagick::Tool::Convert.new do |convert| | |
| convert << "sample.gif" | |
| convert << OUTPUT | |
| end | |
| labels.each do |label| | |
| MiniMagick::Tool::Convert.new do |convert| | |
| convert.instance_eval do | |
| fill(BACKGROUND_COLOR) | |
| font(FONT_PATH) | |
| transparent(BACKGROUND_COLOR) | |
| label(label[:label]) | |
| pointsize(label[:size]) | |
| self << MATERIAL | |
| end | |
| end | |
| MiniMagick::Tool::Convert.new do |convert| | |
| convert << OUTPUT | |
| convert << MATERIAL | |
| convert.geometry(label[:pos]) | |
| convert.composite | |
| convert << OUTPUT | |
| end | |
| end | |
| after = `ps -o rss= -p #{Process.pid}`.to_i | |
| p after - before |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
使用メモリ量は概ね 28kb 程度