ImageMagickで仮画像を文字付きで大量生成

f:id:peroon:20130115183749j:plain
1枚作成するコマンドは、

convert -size 100x100 xc:white -pointsize 10 -draw "text 10,10 xxxtextxxx" output.png

Rubyで回すと、

100.times do |i|

  filename = i.to_s.rjust(4,'0') + '.png'
  command = "convert -size 100x100 xc:yellow -pointsize 30 -draw \"text 20,60 \'ID:" + i.to_s + "\" " + filename
  system(command)
  print '.'
  
  hue = i * 10
  command = 'convert ' + filename + ' -modulate 100,100,'+hue.to_s + ' ' + filename
  system(command)
  
end