class Jekyll::Gensocial::ImageCreator::Composer
Attributes
image[R]
Public Class Methods
new(image_size:)
click to toggle source
# File lib/jekyll-gensocial/image_creator/composer.rb, line 12 def initialize(image_size:) @image_size = image_size @image = Image.new(image_size.width, image_size.height) end
Public Instance Methods
add_bg_layer(config:)
click to toggle source
# File lib/jekyll-gensocial/image_creator/composer.rb, line 17 def add_bg_layer(config:) return if config.path.nil? bg_layer = Image.read(config.path) .first .resize_to_fill(@image_size.width, @image_size.height) @image.composite!(bg_layer, CenterGravity, OverCompositeOp) end
add_text_layer(text, config:)
click to toggle source
# File lib/jekyll-gensocial/image_creator/composer.rb, line 27 def add_text_layer(text, config:) origin = config.rect.origin size = config.rect.size text_layer = Magick::Image.read("caption:#{text}") do self.fill = config.fill self.font = config.font_path unless config.font_path.nil? self.pointsize = config.pointsize self.size = "#{size.width}x#{size.height}" self.background_color = "none" end.first @image.composite!(text_layer, NorthWestGravity, origin.x, origin.y, OverCompositeOp) end