Sha256: 78dc795c8bf098728ed1804632d7236b598d00e59300edf44591adfde0582f35
Contents?: true
Size: 1.1 KB
Versions: 1
Compression:
Stored size: 1.1 KB
Contents
module ImageMosaic module Image #Takes an array of images and metrics and then returns a single image of composited images. class Parent def initialize(items, colour: 'white', columns: 5, dimension: 200) @items = items @colour = colour @columns = columns @dimension = dimension end def create image.run_command(:convert, '-size', "#{WIDTH}x#{HEIGHT}", "xc:#{@colour}", image.path) y = 0 sliced_grid.each do |row| x = 0 row.each do |cell| @image = add_image(cell, x, y) x += @dimension end y += @dimension end image end private def sliced_grid @items.each_slice(@columns).to_a end def add_image(child_image, x, y) Operations::Compositor.new(@image, child_image).save(x, y, type: 'Over', dimension: @dimension) end def temp_file @temp_file ||= Tempfile.new(['image_mosaic', '.png']) end def image @image ||= MiniMagick::Image.new(temp_file.path) end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
image_mosaic-0.1.1 | lib/image_mosaic/image/parent.rb |