Guest User

Untitled

a guest
Apr 23rd, 2018
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.67 KB | None | 0 0
  1. #!/usr/bin/env ruby
  2.  
  3. require 'rubygems'
  4. require 'RMagick'
  5.  
  6. def gen_image(name, width, height)
  7. img = Magick::Image.new(width, height) do |i|
  8. i.background_color = Magick::Pixel.new(rand(Magick::MaxRGB), rand(Magick::MaxRGB), rand(Magick::MaxRGB), 0)
  9. end
  10. point_size = width / 8
  11. (d = Magick::Draw.new).annotate(img, width, height, 0, 0, name) do
  12. d.gravity, d.fill, d.pointsize = Magick::CenterGravity, 'white', point_size
  13. end
  14. img.write "img/#{name}"
  15. end
  16.  
  17. if ARGV.size == 2
  18. width, height= ARGV.shift.split("x").map(&:to_i)
  19. Integer(ARGV.shift).times do |num|
  20. gen_image("%04d.png" % num, width, height)
  21. end
  22. else
  23. puts "[usage] #{$0} [width]x[height] [num]"
  24. end
Add Comment
Please, Sign In to add comment