class Struggle::Tmagick
Public Class Methods
new(img, newimg=nil)
click to toggle source
# File lib/struggle/tmagick.rb, line 3 def initialize(img, newimg=nil) @pushimg = Magick::Image.read(img).first @poppath = newimg.blank? ? img : newimg end
Public Instance Methods
images(images)
click to toggle source
# File lib/struggle/tmagick.rb, line 8 def images(images) return nil if images.blank? images.each do |img| image = Magick::Image.read(img[:img]).first.resize_to_fit(img[:w], img[:h]) @pushimg.composite!(image, img[:x], img[:y], Magick::OverCompositeOp) end return self end
resize(new_width, new_height)
click to toggle source
# File lib/struggle/tmagick.rb, line 30 def resize(new_width, new_height) @pushimg = Magick::Image.read(@pushimg).first.resize_to_fit(new_width, new_height) @pushimg.blank? ? nil : self end
texts(texts)
click to toggle source
# File lib/struggle/tmagick.rb, line 17 def texts(texts) return nil if texts.blank? texts.each do |text| copyright = Magick::Draw.new copyright.font = text[:font] copyright.pointsize = text[:size] copyright.font_weight = text[:weight] copyright.fill = text[:color] copyright.annotate(@pushimg, 0, 0, text[:x], text[:y]+12, text[:text]) end return self end
write()
click to toggle source
# File lib/struggle/tmagick.rb, line 35 def write @pushimg.write(@poppath) end