Sha256: 6a191851762ef5433d654babc4fe2752f8278d30d6b1fba0474667afe26ee24a

Contents?: true

Size: 736 Bytes

Versions: 1

Compression:

Stored size: 736 Bytes

Contents

require 'RMagick'

class GMS
  class Stitcher

    attr_accessor :dir, :output_file

    def initialize(dir, output_file="map.png")
      @dir = dir
      @output_file = output_file
    end

    def tiles
      Dir.glob(File.join(dir,"*")).sort.map do |path|
        Dir.glob(File.join(path,"*.png")).sort.map do |image|
          image
        end
      end
    end

    def process
      output = Magick::ImageList.new

      tiles.each do |row|
        column = Magick::ImageList.new
        row.sort.each do |file|
          puts "Combining #{file}"
          column.push(Magick::Image.read(file).first)
        end
        output.push(column.append(true))
      end
      output.append(false).write(@output_file)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
google-map-stitch-0.1.4 lib/google-map-stitch/stitcher.rb