4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
|
# File 'lib/originals/tool.rb', line 4
def self.main( args=ARGV )
puts "==> welcome to the fab(ricate) tool with args:"
pp args
options = { }
parser = OptionParser.new do |opts|
opts.on("--zoom NUM", "-z", Integer,
"Zoom factor x2, x4, x8, etc. (default: 1)") do |num|
options[ :zoom] = num
end
opts.on("--background STRING", "--bg STRING", "-b", String,
"Background (default: transparent)") do |str|
options[ :background] = str
end
opts.on("--id NUM", "-i", Integer,
"Unique identifier (default: none)") do |str|
options[ :id] = str
end
opts.on("-h", "--help", "Prints this help") do
puts opts
exit
end
end
parser.parse!( args )
puts "options:"
pp options
puts "args:"
pp args
if args.size < 1
puts "!! ERROR - no art series name found - use <name> <attribute>..."
puts ""
exit
end
name = args[0] attributes = args[1..-1]
key = name.downcase.gsub( '[ ()_-]', '' )
img = Original::Image.fabricate( key, *attributes,
background: options[ :background] )
basename = "#{key}#{options[:id]}"
path = if options[:zoom]
img = img.zoom( options[:zoom] )
"./#{basename}@#{options[:zoom]}x.png"
else
"./#{basename}.png"
end
puts " saving original #{name} (#{img.width}x#{img.height}) to >#{path}<..."
img.save( path )
puts "bye"
end
|