Skip to content

Instantly share code, notes, and snippets.

@rosylilly
Created July 5, 2009 03:34
Show Gist options
  • Save rosylilly/140817 to your computer and use it in GitHub Desktop.
Save rosylilly/140817 to your computer and use it in GitHub Desktop.
違う、違うんだ。俺が悪いんじゃない。アイツが俺を殺そうとしたから……!
#!ruby path
ENV['GEM_HOME'] = "gem path"
require 'rubygems'
require 'cgi'
require 'RMagick'
require 'kconv'
print "Content-Type: text/html\n\n"
begin
doc = open('_index.html').read
cgi = CGI.new
unless cgi.params['serif'].to_s == ''
string = cgi.params['serif'].to_s
else
string = "文字入力したら僕が喋るよ"
end
img = nil
if cgi.params['alt'].to_s != 'yes'
img = Magick::ImageList.new('ok photo jpg')
else
img = Magick::ImageList.new('special image jpg')
end
dr = Magick::Draw.new
dr.fill = "#bbddff80"
dr.fill = "#FBC2C980" if cgi.params['alt'].to_s == 'yes'
dr.roundrectangle(40,360,590,460,20,20)
dr.draw(img)
md = Magick::Draw.new
md.annotate(img, 0, 0, 50, 400, string.toutf8) do
md.pointsize = 24
md.font="font path"
md.fill="black"
md.stroke="white" if cgi.params['stroke'].to_s == "yes"
end
img = [img.to_blob].pack('m').gsub("\n",'')
print doc.sub('#image', "<img src=\"data:image/jpg;base64,#{img}\" />")
rescue
puts $!
puts $@
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment