読者です 読者をやめる 読者になる 読者になる

Generative image with gem geo_pattern

f:id:peroon:20140228005659j:plain

https://github.com/jasonlong/geo_pattern

geo_pattern is image generator.

I generate 100 svg images by geo_pattern,
and convert them into jpg images,
and merge them into one image.
require 'geo_pattern'

system('rm -rf output')
system('mkdir output')

for i in 1..100 do
    filename = "%04d" % i + '.jpg'
    pattern = GeoPattern.generate(filename)
    
    File.open('temp.svg', 'wb') do|f|
      f.write(Base64.decode64(pattern.base64_string))
    end
    system('convert -resize 100x100! temp.svg output/' + filename)
    print '.'
end

system('rm temp.svg')

#merge
system('montage -geometry 100x100 -tile 10x10 output/*.jpg merged.jpg')
system('rm -rf output')