Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env ruby
- require 'rubygems'
- require 'RMagick'
- def gen_image(name, width, height)
- img = Magick::Image.new(width, height) do |i|
- i.background_color = Magick::Pixel.new(rand(Magick::MaxRGB), rand(Magick::MaxRGB), rand(Magick::MaxRGB), 0)
- end
- point_size = width / 8
- (d = Magick::Draw.new).annotate(img, width, height, 0, 0, name) do
- d.gravity, d.fill, d.pointsize = Magick::CenterGravity, 'white', point_size
- end
- img.write "img/#{name}"
- end
- if ARGV.size == 2
- width, height= ARGV.shift.split("x").map(&:to_i)
- Integer(ARGV.shift).times do |num|
- gen_image("%04d.png" % num, width, height)
- end
- else
- puts "[usage] #{$0} [width]x[height] [num]"
- end
Add Comment
Please, Sign In to add comment