21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
# File 'app/app.rb', line 21
def convert (string, params)
case content_type
when *[:jpg, :gif, :png]
f = Tempfile.new('cow')
begin
f.write(string)
f.rewind
`convert -font Courier #{dimensions} label:@#{f.path} #{content_type}:-`
ensure
f.close
f.unlink
end
when :html
<<-eos
<html>
<body>
<img style="padding-left:30px" src="#{request.scheme}://#{request.host}/#{params[:name]}/#{params[:say]}.png" />
</body>
</html>
eos
else
string
end
end
|