class Profound::Image
Public Class Methods
new(source, caption, options, destination)
click to toggle source
# File lib/profound.rb, line 71 def initialize(source, caption, options, destination) source = Input.new(source, options).path @source = Magick::ImageList.new(source).first @target = Magick::ImageList.new @destination = destination @caption = caption @options = options @theme = Theme.new(options[:theme]) @font_family = options[:font_family] || 'Helvetica' end
Public Instance Methods
_text(stroke_width = 0)
click to toggle source
# File lib/profound.rb, line 111 def _text(stroke_width = 0) image = Magick::Image.new(@source.columns, line_count(@caption) * 100) { self.background_color = 'none' } text = Magick::Draw.new color = @theme.color font_family = @font_family text.annotate(image, 0, 0, 0, 0, @caption) { self.fill = color self.font_family = font_family self.pointsize = 80 self.stroke_width = stroke_width self.stroke = color self.gravity = Magick::CenterGravity } image rescue Magick::ImageMagickError => e puts "An error has occured. Try installing ghostscript" exit! end
convert()
click to toggle source
# File lib/profound.rb, line 83 def convert shadow text filters save end
filters()
click to toggle source
# File lib/profound.rb, line 94 def filters case @options[:filter] when :toycamera toy_camera end end
line_count(caption)
click to toggle source
# File lib/profound.rb, line 135 def line_count(caption) caption.split("\\n").count end
save()
click to toggle source
# File lib/profound.rb, line 107 def save @source.write(@destination) end
shadow()
click to toggle source
# File lib/profound.rb, line 101 def shadow image = _text(40) shadow = image.shadow(0, 0, line_count(@caption) * 30).colorize(1, 1, 1, 0, @theme.inverse_color) @source = @source.composite(shadow, Magick::CenterGravity, 20, 0, Magick::OverCompositeOp) end
text()
click to toggle source
# File lib/profound.rb, line 90 def text @source = @source.composite(_text, Magick::CenterGravity, Magick::OverCompositeOp) end