moro (owner)

Revisions

gist: 226857 Download_button fork
public
Public Clone URL: git://gist.github.com/226857.git
Embed All Files: show embed
image-stubber #
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#!/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