Module: Jitimage
- Defined in:
- lib/jitimage.rb,
lib/jitimage/config.rb
Defined Under Namespace
Modules: Config
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
Instance Method Details
#jitimage(label = '<no label provided>', options = {}) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/jitimage.rb', line 11 def jitimage(label = '<no label provided>', = {}) = Jitimage::Config.settings.merge() hash = MD5.new("#{label}#{.sort {|a, b| a[0].to_s <=> b[0].to_s}.to_s}") path = "#{RAILS_ROOT}/public/#{[:img_path]}/#{hash}.#{[:format]}".gsub('//', '/') unless File.exist?(path) caption = [:width] ? "-size #{[:width]}x caption:'#{label}'" : "label:'#{label}'" `mkdir -p #{"#{RAILS_ROOT}/public/#{[:img_path]}".gsub('//', '/')}` `convert -background #{[:background]} -fill "#{[:color]}" \ -font #{Jitimage::Fonts.find([:font_dir], [:font])} \ -pointsize #{[:size]} -blur 0x.3 #{caption} #{path}` end image_tag "/#{[:img_path]}/#{hash}.#{[:format]}".gsub('//', '/'), :class => (['jitimage'] << [:class]).compact.join(' '), :alt => label end |