image_processing 0.4.5 → 0.9.0
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of image_processing might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/CHANGELOG.md +65 -0
- data/README.md +366 -26
- data/image_processing.gemspec +3 -2
- data/lib/image_processing.rb +1 -0
- data/lib/image_processing/mini_magick.rb +1 -1
- data/lib/image_processing/version.rb +1 -1
- data/lib/image_processing/vips.rb +13 -0
- data/lib/image_processing/vips/chainable.rb +61 -0
- data/lib/image_processing/vips/color.rb +584 -0
- data/lib/image_processing/vips/pipeline.rb +30 -0
- data/lib/image_processing/vips/processor.rb +83 -0
- metadata +24 -4
data/image_processing.gemspec
CHANGED
@@ -13,12 +13,13 @@ Gem::Specification.new do |spec|
|
|
13
13
|
spec.email = ["janko.marohnic@gmail.com"]
|
14
14
|
spec.license = "MIT"
|
15
15
|
|
16
|
-
spec.files = Dir["README.md", "LICENSE.txt", "lib
|
16
|
+
spec.files = Dir["README.md", "LICENSE.txt", "CHANGELOG.md", "lib/**/*.rb", "*.gemspec"]
|
17
17
|
spec.require_paths = ["lib"]
|
18
18
|
|
19
19
|
spec.add_development_dependency "minitest", "~> 5.8"
|
20
|
-
spec.add_development_dependency "minitest-hooks"
|
20
|
+
spec.add_development_dependency "minitest-hooks", ">= 1.4.2"
|
21
21
|
spec.add_development_dependency "minispec-metadata"
|
22
22
|
spec.add_development_dependency "mini_magick", ">= 4.3.5"
|
23
|
+
spec.add_development_dependency "ruby-vips", ">= 2.0.0"
|
23
24
|
spec.add_development_dependency "phashion" unless RUBY_ENGINE == "jruby"
|
24
25
|
end
|
data/lib/image_processing.rb
CHANGED
@@ -227,7 +227,7 @@ module ImageProcessing
|
|
227
227
|
# IO object that responds to `#read(length = nil, outbuf = nil)`.
|
228
228
|
def _copy_to_tempfile(file)
|
229
229
|
extension = File.extname(file.path) if file.respond_to?(:path)
|
230
|
-
tempfile = Tempfile.new(["mini_magick", extension.to_s], binmode: true)
|
230
|
+
tempfile = Tempfile.new(["image_processing-mini_magick", extension.to_s], binmode: true)
|
231
231
|
IO.copy_stream(file, tempfile.path)
|
232
232
|
file.rewind
|
233
233
|
tempfile
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require "image_processing/vips/chainable"
|
2
|
+
require "image_processing/vips/pipeline"
|
3
|
+
require "image_processing/vips/processor"
|
4
|
+
|
5
|
+
require "image_processing/version"
|
6
|
+
|
7
|
+
module ImageProcessing
|
8
|
+
module Vips
|
9
|
+
Error = Class.new(StandardError)
|
10
|
+
|
11
|
+
extend Chainable
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,61 @@
|
|
1
|
+
module ImageProcessing
|
2
|
+
module Vips
|
3
|
+
module Chainable
|
4
|
+
def source(file)
|
5
|
+
branch default_options.merge(source: file)
|
6
|
+
end
|
7
|
+
|
8
|
+
def convert(format)
|
9
|
+
branch default_options.merge(format: format)
|
10
|
+
end
|
11
|
+
|
12
|
+
def loader(**options)
|
13
|
+
loader = default_options[:loader].merge(options)
|
14
|
+
branch default_options.merge(loader: loader)
|
15
|
+
end
|
16
|
+
|
17
|
+
def saver(**options)
|
18
|
+
saver = default_options[:saver].merge(options)
|
19
|
+
branch default_options.merge(saver: saver)
|
20
|
+
end
|
21
|
+
|
22
|
+
def operation(name, *args)
|
23
|
+
operations = default_options[:operations] + [[name, args]]
|
24
|
+
branch default_options.merge(operations: operations)
|
25
|
+
end
|
26
|
+
|
27
|
+
def custom(&block)
|
28
|
+
operation(:custom, block)
|
29
|
+
end
|
30
|
+
|
31
|
+
def method_missing(name, *args)
|
32
|
+
if name.to_s.end_with?("!")
|
33
|
+
send(name.to_s.chomp("!"), *args).call!
|
34
|
+
else
|
35
|
+
operation(name, *args)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
def call(file = nil, save: true)
|
40
|
+
options = default_options
|
41
|
+
options = options.merge(source: file) if file
|
42
|
+
|
43
|
+
branch(options).call!(save: save)
|
44
|
+
end
|
45
|
+
|
46
|
+
def branch(options)
|
47
|
+
Pipeline.new(options)
|
48
|
+
end
|
49
|
+
|
50
|
+
def default_options
|
51
|
+
@default_options ||= {
|
52
|
+
source: nil,
|
53
|
+
loader: {},
|
54
|
+
saver: {},
|
55
|
+
format: nil,
|
56
|
+
operations: [],
|
57
|
+
}
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
@@ -0,0 +1,584 @@
|
|
1
|
+
module ImageProcessing
|
2
|
+
module Vips
|
3
|
+
module Color
|
4
|
+
MAPPING = {
|
5
|
+
"snow" => [255, 250, 250],
|
6
|
+
"snow1" => [255, 250, 250],
|
7
|
+
"snow2" => [238, 233, 233],
|
8
|
+
"rosybrown1" => [255, 193, 193],
|
9
|
+
"rosybrown2" => [238, 180, 180],
|
10
|
+
"snow3" => [205, 201, 201],
|
11
|
+
"lightcoral" => [240, 128, 128],
|
12
|
+
"indianred1" => [255, 106, 106],
|
13
|
+
"rosybrown3" => [205, 155, 155],
|
14
|
+
"indianred2" => [238, 99, 99],
|
15
|
+
"rosybrown" => [188, 143, 143],
|
16
|
+
"brown1" => [255, 64, 64],
|
17
|
+
"firebrick1" => [255, 48, 48],
|
18
|
+
"brown2" => [238, 59, 59],
|
19
|
+
"indianred" => [205, 92, 92],
|
20
|
+
"indianred3" => [205, 85, 85],
|
21
|
+
"firebrick2" => [238, 44, 44],
|
22
|
+
"snow4" => [139, 137, 137],
|
23
|
+
"brown3" => [205, 51, 51],
|
24
|
+
"red" => [255, 0, 0],
|
25
|
+
"red1" => [255, 0, 0],
|
26
|
+
"rosybrown4" => [139, 105, 105],
|
27
|
+
"firebrick3" => [205, 38, 38],
|
28
|
+
"red2" => [238, 0, 0],
|
29
|
+
"firebrick" => [178, 34, 34],
|
30
|
+
"brown" => [165, 42, 42],
|
31
|
+
"red3" => [205, 0, 0],
|
32
|
+
"indianred4" => [139, 58, 58],
|
33
|
+
"brown4" => [139, 35, 35],
|
34
|
+
"firebrick4" => [139, 26, 26],
|
35
|
+
"darkred" => [139, 0, 0],
|
36
|
+
"red4" => [139, 0, 0],
|
37
|
+
"maroon" => [176, 48, 96],
|
38
|
+
"lightpink1" => [255, 174, 185],
|
39
|
+
"lightpink3" => [205, 140, 149],
|
40
|
+
"lightpink4" => [139, 95, 101],
|
41
|
+
"lightpink2" => [238, 162, 173],
|
42
|
+
"lightpink" => [255, 182, 193],
|
43
|
+
"pink" => [255, 192, 203],
|
44
|
+
"crimson" => [220, 20, 60],
|
45
|
+
"pink1" => [255, 181, 197],
|
46
|
+
"pink2" => [238, 169, 184],
|
47
|
+
"pink3" => [205, 145, 158],
|
48
|
+
"pink4" => [139, 99, 108],
|
49
|
+
"palevioletred4" => [139, 71, 93],
|
50
|
+
"palevioletred" => [219, 112, 147],
|
51
|
+
"palevioletred2" => [238, 121, 159],
|
52
|
+
"palevioletred1" => [255, 130, 171],
|
53
|
+
"palevioletred3" => [205, 104, 137],
|
54
|
+
"lavenderblush" => [255, 240, 245],
|
55
|
+
"lavenderblush1" => [255, 240, 245],
|
56
|
+
"lavenderblush3" => [205, 193, 197],
|
57
|
+
"lavenderblush2" => [238, 224, 229],
|
58
|
+
"lavenderblush4" => [139, 131, 134],
|
59
|
+
"hotpink3" => [205, 96, 144],
|
60
|
+
"violetred3" => [205, 50, 120],
|
61
|
+
"violetred1" => [255, 62, 150],
|
62
|
+
"violetred2" => [238, 58, 140],
|
63
|
+
"violetred4" => [139, 34, 82],
|
64
|
+
"hotpink2" => [238, 106, 167],
|
65
|
+
"hotpink1" => [255, 110, 180],
|
66
|
+
"hotpink4" => [139, 58, 98],
|
67
|
+
"hotpink" => [255, 105, 180],
|
68
|
+
"deeppink" => [255, 20, 147],
|
69
|
+
"deeppink1" => [255, 20, 147],
|
70
|
+
"deeppink2" => [238, 18, 137],
|
71
|
+
"deeppink3" => [205, 16, 118],
|
72
|
+
"deeppink4" => [139, 10, 80],
|
73
|
+
"maroon1" => [255, 52, 179],
|
74
|
+
"maroon2" => [238, 48, 167],
|
75
|
+
"maroon3" => [205, 41, 144],
|
76
|
+
"maroon4" => [139, 28, 98],
|
77
|
+
"mediumvioletred" => [199, 21, 133],
|
78
|
+
"violetred" => [208, 32, 144],
|
79
|
+
"orchid2" => [238, 122, 233],
|
80
|
+
"orchid" => [218, 112, 214],
|
81
|
+
"orchid1" => [255, 131, 250],
|
82
|
+
"orchid3" => [205, 105, 201],
|
83
|
+
"orchid4" => [139, 71, 137],
|
84
|
+
"thistle1" => [255, 225, 255],
|
85
|
+
"thistle2" => [238, 210, 238],
|
86
|
+
"plum1" => [255, 187, 255],
|
87
|
+
"plum2" => [238, 174, 238],
|
88
|
+
"thistle" => [216, 191, 216],
|
89
|
+
"thistle3" => [205, 181, 205],
|
90
|
+
"plum" => [221, 160, 221],
|
91
|
+
"violet" => [238, 130, 238],
|
92
|
+
"plum3" => [205, 150, 205],
|
93
|
+
"thistle4" => [139, 123, 139],
|
94
|
+
"fuchsia" => [255, 0, 255],
|
95
|
+
"magenta" => [255, 0, 255],
|
96
|
+
"magenta1" => [255, 0, 255],
|
97
|
+
"plum4" => [139, 102, 139],
|
98
|
+
"magenta2" => [238, 0, 238],
|
99
|
+
"magenta3" => [205, 0, 205],
|
100
|
+
"darkmagenta" => [139, 0, 139],
|
101
|
+
"magenta4" => [139, 0, 139],
|
102
|
+
"purple" => [160, 32, 240],
|
103
|
+
"mediumorchid" => [186, 85, 211],
|
104
|
+
"mediumorchid1" => [224, 102, 255],
|
105
|
+
"mediumorchid2" => [209, 95, 238],
|
106
|
+
"mediumorchid3" => [180, 82, 205],
|
107
|
+
"mediumorchid4" => [122, 55, 139],
|
108
|
+
"darkviolet" => [148, 0, 211],
|
109
|
+
"darkorchid" => [153, 50, 204],
|
110
|
+
"darkorchid1" => [191, 62, 255],
|
111
|
+
"darkorchid3" => [154, 50, 205],
|
112
|
+
"darkorchid2" => [178, 58, 238],
|
113
|
+
"darkorchid4" => [104, 34, 139],
|
114
|
+
"indigo" => [ 75, 0, 130],
|
115
|
+
"blueviolet" => [138, 43, 226],
|
116
|
+
"purple2" => [145, 44, 238],
|
117
|
+
"purple3" => [125, 38, 205],
|
118
|
+
"purple4" => [ 85, 26, 139],
|
119
|
+
"purple1" => [155, 48, 255],
|
120
|
+
"mediumpurple" => [147, 112, 219],
|
121
|
+
"mediumpurple1" => [171, 130, 255],
|
122
|
+
"mediumpurple2" => [159, 121, 238],
|
123
|
+
"mediumpurple3" => [137, 104, 205],
|
124
|
+
"mediumpurple4" => [ 93, 71, 139],
|
125
|
+
"darkslateblue" => [ 72, 61, 139],
|
126
|
+
"lightslateblue" => [132, 112, 255],
|
127
|
+
"mediumslateblue" => [123, 104, 238],
|
128
|
+
"slateblue" => [106, 90, 205],
|
129
|
+
"slateblue1" => [131, 111, 255],
|
130
|
+
"slateblue2" => [122, 103, 238],
|
131
|
+
"slateblue3" => [105, 89, 205],
|
132
|
+
"slateblue4" => [ 71, 60, 139],
|
133
|
+
"ghostwhite" => [248, 248, 255],
|
134
|
+
"lavender" => [230, 230, 250],
|
135
|
+
"blue" => [ 0, 0, 255],
|
136
|
+
"blue1" => [ 0, 0, 255],
|
137
|
+
"blue2" => [ 0, 0, 238],
|
138
|
+
"blue3" => [ 0, 0, 205],
|
139
|
+
"mediumblue" => [ 0, 0, 205],
|
140
|
+
"blue4" => [ 0, 0, 139],
|
141
|
+
"darkblue" => [ 0, 0, 139],
|
142
|
+
"midnightblue" => [ 25, 25, 112],
|
143
|
+
"navy" => [ 0, 0, 128],
|
144
|
+
"navyblue" => [ 0, 0, 128],
|
145
|
+
"royalblue" => [ 65, 105, 225],
|
146
|
+
"royalblue1" => [ 72, 118, 255],
|
147
|
+
"royalblue2" => [ 67, 110, 238],
|
148
|
+
"royalblue3" => [ 58, 95, 205],
|
149
|
+
"royalblue4" => [ 39, 64, 139],
|
150
|
+
"cornflowerblue" => [100, 149, 237],
|
151
|
+
"lightsteelblue" => [176, 196, 222],
|
152
|
+
"lightsteelblue1" => [202, 225, 255],
|
153
|
+
"lightsteelblue2" => [188, 210, 238],
|
154
|
+
"lightsteelblue3" => [162, 181, 205],
|
155
|
+
"lightsteelblue4" => [110, 123, 139],
|
156
|
+
"slategrey4" => [108, 123, 139],
|
157
|
+
"slategrey1" => [198, 226, 255],
|
158
|
+
"slategrey2" => [185, 211, 238],
|
159
|
+
"slategrey3" => [159, 182, 205],
|
160
|
+
"lightslategrey" => [119, 136, 153],
|
161
|
+
"slategrey" => [112, 128, 144],
|
162
|
+
"dodgerblue" => [ 30, 144, 255],
|
163
|
+
"dodgerblue1" => [ 30, 144, 255],
|
164
|
+
"dodgerblue2" => [ 28, 134, 238],
|
165
|
+
"dodgerblue4" => [ 16, 78, 139],
|
166
|
+
"dodgerblue3" => [ 24, 116, 205],
|
167
|
+
"aliceblue" => [240, 248, 255],
|
168
|
+
"steelblue4" => [ 54, 100, 139],
|
169
|
+
"steelblue" => [ 70, 130, 180],
|
170
|
+
"steelblue1" => [ 99, 184, 255],
|
171
|
+
"steelblue2" => [ 92, 172, 238],
|
172
|
+
"steelblue3" => [ 79, 148, 205],
|
173
|
+
"skyblue4" => [ 74, 112, 139],
|
174
|
+
"skyblue1" => [135, 206, 255],
|
175
|
+
"skyblue2" => [126, 192, 238],
|
176
|
+
"skyblue3" => [108, 166, 205],
|
177
|
+
"lightskyblue" => [135, 206, 250],
|
178
|
+
"lightskyblue4" => [ 96, 123, 139],
|
179
|
+
"lightskyblue1" => [176, 226, 255],
|
180
|
+
"lightskyblue2" => [164, 211, 238],
|
181
|
+
"lightskyblue3" => [141, 182, 205],
|
182
|
+
"skyblue" => [135, 206, 235],
|
183
|
+
"lightblue3" => [154, 192, 205],
|
184
|
+
"deepskyblue" => [ 0, 191, 255],
|
185
|
+
"deepskyblue1" => [ 0, 191, 255],
|
186
|
+
"deepskyblue2" => [ 0, 178, 238],
|
187
|
+
"deepskyblue4" => [ 0, 104, 139],
|
188
|
+
"deepskyblue3" => [ 0, 154, 205],
|
189
|
+
"lightblue1" => [191, 239, 255],
|
190
|
+
"lightblue2" => [178, 223, 238],
|
191
|
+
"lightblue" => [173, 216, 230],
|
192
|
+
"lightblue4" => [104, 131, 139],
|
193
|
+
"powderblue" => [176, 224, 230],
|
194
|
+
"cadetblue1" => [152, 245, 255],
|
195
|
+
"cadetblue2" => [142, 229, 238],
|
196
|
+
"cadetblue3" => [122, 197, 205],
|
197
|
+
"cadetblue4" => [ 83, 134, 139],
|
198
|
+
"turquoise1" => [ 0, 245, 255],
|
199
|
+
"turquoise2" => [ 0, 229, 238],
|
200
|
+
"turquoise3" => [ 0, 197, 205],
|
201
|
+
"turquoise4" => [ 0, 134, 139],
|
202
|
+
"cadet blue" => [ 95, 158, 160],
|
203
|
+
"cadetblue" => [ 95, 158, 160],
|
204
|
+
"darkturquoise" => [ 0, 206, 209],
|
205
|
+
"azure" => [240, 255, 255],
|
206
|
+
"azure1" => [240, 255, 255],
|
207
|
+
"lightcyan" => [224, 255, 255],
|
208
|
+
"lightcyan1" => [224, 255, 255],
|
209
|
+
"azure2" => [224, 238, 238],
|
210
|
+
"lightcyan2" => [209, 238, 238],
|
211
|
+
"paleturquoise1" => [187, 255, 255],
|
212
|
+
"paleturquoise" => [175, 238, 238],
|
213
|
+
"paleturquoise2" => [174, 238, 238],
|
214
|
+
"darkslategrey1" => [151, 255, 255],
|
215
|
+
"azure3" => [193, 205, 205],
|
216
|
+
"lightcyan3" => [180, 205, 205],
|
217
|
+
"darkslategrey2" => [141, 238, 238],
|
218
|
+
"paleturquoise3" => [150, 205, 205],
|
219
|
+
"darkslategrey3" => [121, 205, 205],
|
220
|
+
"azure4" => [131, 139, 139],
|
221
|
+
"lightcyan4" => [122, 139, 139],
|
222
|
+
"aqua" => [ 0, 255, 255],
|
223
|
+
"cyan" => [ 0, 255, 255],
|
224
|
+
"cyan1" => [ 0, 255, 255],
|
225
|
+
"paleturquoise4" => [102, 139, 139],
|
226
|
+
"cyan2" => [ 0, 238, 238],
|
227
|
+
"darkslategrey4" => [ 82, 139, 139],
|
228
|
+
"cyan3" => [ 0, 205, 205],
|
229
|
+
"cyan4" => [ 0, 139, 139],
|
230
|
+
"darkcyan" => [ 0, 139, 139],
|
231
|
+
"teal" => [ 0, 128, 128],
|
232
|
+
"darkslategrey" => [ 47, 79, 79],
|
233
|
+
"mediumturquoise" => [ 72, 209, 204],
|
234
|
+
"lightseagreen" => [ 32, 178, 170],
|
235
|
+
"turquoise" => [ 64, 224, 208],
|
236
|
+
"aquamarine4" => [ 69, 139, 116],
|
237
|
+
"aquamarine" => [127, 255, 212],
|
238
|
+
"aquamarine1" => [127, 255, 212],
|
239
|
+
"aquamarine2" => [118, 238, 198],
|
240
|
+
"aquamarine3" => [102, 205, 170],
|
241
|
+
"mediumaquamarine" => [102, 205, 170],
|
242
|
+
"mediumspringgreen" => [ 0, 250, 154],
|
243
|
+
"mintcream" => [245, 255, 250],
|
244
|
+
"springgreen" => [ 0, 255, 127],
|
245
|
+
"springgreen1" => [ 0, 255, 127],
|
246
|
+
"springgreen2" => [ 0, 238, 118],
|
247
|
+
"springgreen3" => [ 0, 205, 102],
|
248
|
+
"springgreen4" => [ 0, 139, 69],
|
249
|
+
"mediumseagreen" => [ 60, 179, 113],
|
250
|
+
"seagreen" => [ 46, 139, 87],
|
251
|
+
"seagreen3" => [ 67, 205, 128],
|
252
|
+
"seagreen1" => [ 84, 255, 159],
|
253
|
+
"seagreen4" => [ 46, 139, 87],
|
254
|
+
"seagreen2" => [ 78, 238, 148],
|
255
|
+
"mediumforestgreen" => [ 50, 129, 75],
|
256
|
+
"honeydew" => [240, 255, 240],
|
257
|
+
"honeydew1" => [240, 255, 240],
|
258
|
+
"honeydew2" => [224, 238, 224],
|
259
|
+
"darkseagreen1" => [193, 255, 193],
|
260
|
+
"darkseagreen2" => [180, 238, 180],
|
261
|
+
"palegreen1" => [154, 255, 154],
|
262
|
+
"palegreen" => [152, 251, 152],
|
263
|
+
"honeydew3" => [193, 205, 193],
|
264
|
+
"lightgreen" => [144, 238, 144],
|
265
|
+
"palegreen2" => [144, 238, 144],
|
266
|
+
"darkseagreen3" => [155, 205, 155],
|
267
|
+
"darkseagreen" => [143, 188, 143],
|
268
|
+
"palegreen3" => [124, 205, 124],
|
269
|
+
"honeydew4" => [131, 139, 131],
|
270
|
+
"green1" => [ 0, 255, 0],
|
271
|
+
"lime" => [ 0, 255, 0],
|
272
|
+
"limegreen" => [ 50, 205, 50],
|
273
|
+
"darkseagreen4" => [105, 139, 105],
|
274
|
+
"green2" => [ 0, 238, 0],
|
275
|
+
"palegreen4" => [ 84, 139, 84],
|
276
|
+
"green3" => [ 0, 205, 0],
|
277
|
+
"forestgreen" => [ 34, 139, 34],
|
278
|
+
"green4" => [ 0, 139, 0],
|
279
|
+
"green" => [ 0, 128, 0],
|
280
|
+
"darkgreen" => [ 0, 100, 0],
|
281
|
+
"lawngreen" => [124, 252, 0],
|
282
|
+
"chartreuse" => [127, 255, 0],
|
283
|
+
"chartreuse1" => [127, 255, 0],
|
284
|
+
"chartreuse2" => [118, 238, 0],
|
285
|
+
"chartreuse3" => [102, 205, 0],
|
286
|
+
"chartreuse4" => [ 69, 139, 0],
|
287
|
+
"greenyellow" => [173, 255, 47],
|
288
|
+
"darkolivegreen3" => [162, 205, 90],
|
289
|
+
"darkolivegreen1" => [202, 255, 112],
|
290
|
+
"darkolivegreen2" => [188, 238, 104],
|
291
|
+
"darkolivegreen4" => [110, 139, 61],
|
292
|
+
"darkolivegreen" => [ 85, 107, 47],
|
293
|
+
"olivedrab" => [107, 142, 35],
|
294
|
+
"olivedrab1" => [192, 255, 62],
|
295
|
+
"olivedrab2" => [179, 238, 58],
|
296
|
+
"olivedrab3" => [154, 205, 50],
|
297
|
+
"yellowgreen" => [154, 205, 50],
|
298
|
+
"olivedrab4" => [105, 139, 34],
|
299
|
+
"ivory" => [255, 255, 240],
|
300
|
+
"ivory1" => [255, 255, 240],
|
301
|
+
"lightyellow" => [255, 255, 224],
|
302
|
+
"lightyellow1" => [255, 255, 224],
|
303
|
+
"beige" => [245, 245, 220],
|
304
|
+
"ivory2" => [238, 238, 224],
|
305
|
+
"lightgoldenrodyellow" => [250, 250, 210],
|
306
|
+
"lightyellow2" => [238, 238, 209],
|
307
|
+
"ivory3" => [205, 205, 193],
|
308
|
+
"lightyellow3" => [205, 205, 180],
|
309
|
+
"ivory4" => [139, 139, 131],
|
310
|
+
"lightyellow4" => [139, 139, 122],
|
311
|
+
"yellow" => [255, 255, 0],
|
312
|
+
"yellow1" => [255, 255, 0],
|
313
|
+
"yellow2" => [238, 238, 0],
|
314
|
+
"yellow3" => [205, 205, 0],
|
315
|
+
"yellow4" => [139, 139, 0],
|
316
|
+
"olive" => [128, 128, 0],
|
317
|
+
"darkkhaki" => [189, 183, 107],
|
318
|
+
"khaki2" => [238, 230, 133],
|
319
|
+
"lemonchiffon4" => [139, 137, 112],
|
320
|
+
"khaki1" => [255, 246, 143],
|
321
|
+
"khaki3" => [205, 198, 115],
|
322
|
+
"khaki4" => [139, 134, 78],
|
323
|
+
"palegoldenrod" => [238, 232, 170],
|
324
|
+
"lemonchiffon" => [255, 250, 205],
|
325
|
+
"lemonchiffon1" => [255, 250, 205],
|
326
|
+
"khaki" => [240, 230, 140],
|
327
|
+
"lemonchiffon3" => [205, 201, 165],
|
328
|
+
"lemonchiffon2" => [238, 233, 191],
|
329
|
+
"mediumgoldenrod" => [209, 193, 102],
|
330
|
+
"cornsilk4" => [139, 136, 120],
|
331
|
+
"gold" => [255, 215, 0],
|
332
|
+
"gold1" => [255, 215, 0],
|
333
|
+
"gold2" => [238, 201, 0],
|
334
|
+
"gold3" => [205, 173, 0],
|
335
|
+
"gold4" => [139, 117, 0],
|
336
|
+
"lightgoldenrod" => [238, 221, 130],
|
337
|
+
"lightgoldenrod4" => [139, 129, 76],
|
338
|
+
"lightgoldenrod1" => [255, 236, 139],
|
339
|
+
"lightgoldenrod3" => [205, 190, 112],
|
340
|
+
"lightgoldenrod2" => [238, 220, 130],
|
341
|
+
"cornsilk3" => [205, 200, 177],
|
342
|
+
"cornsilk2" => [238, 232, 205],
|
343
|
+
"cornsilk" => [255, 248, 220],
|
344
|
+
"cornsilk1" => [255, 248, 220],
|
345
|
+
"goldenrod" => [218, 165, 32],
|
346
|
+
"goldenrod1" => [255, 193, 37],
|
347
|
+
"goldenrod2" => [238, 180, 34],
|
348
|
+
"goldenrod3" => [205, 155, 29],
|
349
|
+
"goldenrod4" => [139, 105, 20],
|
350
|
+
"darkgoldenrod" => [184, 134, 11],
|
351
|
+
"darkgoldenrod1" => [255, 185, 15],
|
352
|
+
"darkgoldenrod2" => [238, 173, 14],
|
353
|
+
"darkgoldenrod3" => [205, 149, 12],
|
354
|
+
"darkgoldenrod4" => [139, 101, 8],
|
355
|
+
"floralwhite" => [255, 250, 240],
|
356
|
+
"wheat2" => [238, 216, 174],
|
357
|
+
"oldlace" => [253, 245, 230],
|
358
|
+
"wheat" => [245, 222, 179],
|
359
|
+
"wheat1" => [255, 231, 186],
|
360
|
+
"wheat3" => [205, 186, 150],
|
361
|
+
"orange" => [255, 165, 0],
|
362
|
+
"orange1" => [255, 165, 0],
|
363
|
+
"orange2" => [238, 154, 0],
|
364
|
+
"orange3" => [205, 133, 0],
|
365
|
+
"orange4" => [139, 90, 0],
|
366
|
+
"wheat4" => [139, 126, 102],
|
367
|
+
"moccasin" => [255, 228, 181],
|
368
|
+
"papayawhip" => [255, 239, 213],
|
369
|
+
"navajowhite3" => [205, 179, 139],
|
370
|
+
"blanchedalmond" => [255, 235, 205],
|
371
|
+
"navajowhite" => [255, 222, 173],
|
372
|
+
"navajowhite1" => [255, 222, 173],
|
373
|
+
"navajowhite2" => [238, 207, 161],
|
374
|
+
"navajowhite4" => [139, 121, 94],
|
375
|
+
"antiquewhite4" => [139, 131, 120],
|
376
|
+
"antiquewhite" => [250, 235, 215],
|
377
|
+
"tan" => [210, 180, 140],
|
378
|
+
"bisque4" => [139, 125, 107],
|
379
|
+
"burlywood" => [222, 184, 135],
|
380
|
+
"antiquewhite2" => [238, 223, 204],
|
381
|
+
"burlywood1" => [255, 211, 155],
|
382
|
+
"burlywood3" => [205, 170, 125],
|
383
|
+
"burlywood2" => [238, 197, 145],
|
384
|
+
"antiquewhite1" => [255, 239, 219],
|
385
|
+
"burlywood4" => [139, 115, 85],
|
386
|
+
"antiquewhite3" => [205, 192, 176],
|
387
|
+
"darkorange" => [255, 140, 0],
|
388
|
+
"bisque2" => [238, 213, 183],
|
389
|
+
"bisque" => [255, 228, 196],
|
390
|
+
"bisque1" => [255, 228, 196],
|
391
|
+
"bisque3" => [205, 183, 158],
|
392
|
+
"darkorange1" => [255, 127, 0],
|
393
|
+
"linen" => [250, 240, 230],
|
394
|
+
"darkorange2" => [238, 118, 0],
|
395
|
+
"darkorange3" => [205, 102, 0],
|
396
|
+
"darkorange4" => [139, 69, 0],
|
397
|
+
"peru" => [205, 133, 63],
|
398
|
+
"tan1" => [255, 165, 79],
|
399
|
+
"tan2" => [238, 154, 73],
|
400
|
+
"tan3" => [205, 133, 63],
|
401
|
+
"tan4" => [139, 90, 43],
|
402
|
+
"peachpuff" => [255, 218, 185],
|
403
|
+
"peachpuff1" => [255, 218, 185],
|
404
|
+
"peachpuff4" => [139, 119, 101],
|
405
|
+
"peachpuff2" => [238, 203, 173],
|
406
|
+
"peachpuff3" => [205, 175, 149],
|
407
|
+
"sandybrown" => [244, 164, 96],
|
408
|
+
"seashell4" => [139, 134, 130],
|
409
|
+
"seashell2" => [238, 229, 222],
|
410
|
+
"seashell3" => [205, 197, 191],
|
411
|
+
"chocolate" => [210, 105, 30],
|
412
|
+
"chocolate1" => [255, 127, 36],
|
413
|
+
"chocolate2" => [238, 118, 33],
|
414
|
+
"chocolate3" => [205, 102, 29],
|
415
|
+
"chocolate4" => [139, 69, 19],
|
416
|
+
"saddlebrown" => [139, 69, 19],
|
417
|
+
"seashell" => [255, 245, 238],
|
418
|
+
"seashell1" => [255, 245, 238],
|
419
|
+
"sienna4" => [139, 71, 38],
|
420
|
+
"sienna" => [160, 82, 45],
|
421
|
+
"sienna1" => [255, 130, 71],
|
422
|
+
"sienna2" => [238, 121, 66],
|
423
|
+
"sienna3" => [205, 104, 57],
|
424
|
+
"lightsalmon3" => [205, 129, 98],
|
425
|
+
"lightsalmon" => [255, 160, 122],
|
426
|
+
"lightsalmon1" => [255, 160, 122],
|
427
|
+
"lightsalmon4" => [139, 87, 66],
|
428
|
+
"lightsalmon2" => [238, 149, 114],
|
429
|
+
"coral" => [255, 127, 80],
|
430
|
+
"orangered" => [255, 69, 0],
|
431
|
+
"orangered1" => [255, 69, 0],
|
432
|
+
"orangered2" => [238, 64, 0],
|
433
|
+
"orangered3" => [205, 55, 0],
|
434
|
+
"orangered4" => [139, 37, 0],
|
435
|
+
"darksalmon" => [233, 150, 122],
|
436
|
+
"salmon1" => [255, 140, 105],
|
437
|
+
"salmon2" => [238, 130, 98],
|
438
|
+
"salmon3" => [205, 112, 84],
|
439
|
+
"salmon4" => [139, 76, 57],
|
440
|
+
"coral1" => [255, 114, 86],
|
441
|
+
"coral2" => [238, 106, 80],
|
442
|
+
"coral3" => [205, 91, 69],
|
443
|
+
"coral4" => [139, 62, 47],
|
444
|
+
"tomato4" => [139, 54, 38],
|
445
|
+
"tomato" => [255, 99, 71],
|
446
|
+
"tomato1" => [255, 99, 71],
|
447
|
+
"tomato2" => [238, 92, 66],
|
448
|
+
"tomato3" => [205, 79, 57],
|
449
|
+
"mistyrose4" => [139, 125, 123],
|
450
|
+
"mistyrose2" => [238, 213, 210],
|
451
|
+
"mistyrose" => [255, 228, 225],
|
452
|
+
"mistyrose1" => [255, 228, 225],
|
453
|
+
"salmon" => [250, 128, 114],
|
454
|
+
"mistyrose3" => [205, 183, 181],
|
455
|
+
"white" => [255, 255, 255],
|
456
|
+
"grey100" => [255, 255, 255],
|
457
|
+
"grey99" => [252, 252, 252],
|
458
|
+
"grey98" => [250, 250, 250],
|
459
|
+
"grey97" => [247, 247, 247],
|
460
|
+
"grey96" => [245, 245, 245],
|
461
|
+
"whitesmoke" => [245, 245, 245],
|
462
|
+
"grey95" => [242, 242, 242],
|
463
|
+
"grey94" => [240, 240, 240],
|
464
|
+
"grey93" => [237, 237, 237],
|
465
|
+
"grey92" => [235, 235, 235],
|
466
|
+
"grey91" => [232, 232, 232],
|
467
|
+
"grey90" => [229, 229, 229],
|
468
|
+
"grey89" => [227, 227, 227],
|
469
|
+
"grey88" => [224, 224, 224],
|
470
|
+
"grey87" => [222, 222, 222],
|
471
|
+
"gainsboro" => [220, 220, 220],
|
472
|
+
"grey86" => [219, 219, 219],
|
473
|
+
"grey85" => [217, 217, 217],
|
474
|
+
"grey84" => [214, 214, 214],
|
475
|
+
"grey83" => [212, 212, 212],
|
476
|
+
"lightgrey" => [211, 211, 211],
|
477
|
+
"grey82" => [209, 209, 209],
|
478
|
+
"grey81" => [207, 207, 207],
|
479
|
+
"grey80" => [204, 204, 204],
|
480
|
+
"grey79" => [201, 201, 201],
|
481
|
+
"grey78" => [199, 199, 199],
|
482
|
+
"grey77" => [196, 196, 196],
|
483
|
+
"grey76" => [194, 194, 194],
|
484
|
+
"silver" => [192, 192, 192],
|
485
|
+
"grey75" => [191, 191, 191],
|
486
|
+
"grey74" => [189, 189, 189],
|
487
|
+
"grey73" => [186, 186, 186],
|
488
|
+
"grey72" => [184, 184, 184],
|
489
|
+
"grey71" => [181, 181, 181],
|
490
|
+
"grey70" => [179, 179, 179],
|
491
|
+
"grey69" => [176, 176, 176],
|
492
|
+
"grey68" => [173, 173, 173],
|
493
|
+
"grey67" => [171, 171, 171],
|
494
|
+
"darkgrey" => [169, 169, 169],
|
495
|
+
"grey66" => [168, 168, 168],
|
496
|
+
"grey65" => [166, 166, 166],
|
497
|
+
"grey64" => [163, 163, 163],
|
498
|
+
"grey63" => [161, 161, 161],
|
499
|
+
"grey62" => [158, 158, 158],
|
500
|
+
"grey61" => [156, 156, 156],
|
501
|
+
"grey60" => [153, 153, 153],
|
502
|
+
"grey59" => [150, 150, 150],
|
503
|
+
"grey58" => [148, 148, 148],
|
504
|
+
"grey57" => [145, 145, 145],
|
505
|
+
"grey56" => [143, 143, 143],
|
506
|
+
"grey55" => [140, 140, 140],
|
507
|
+
"grey54" => [138, 138, 138],
|
508
|
+
"grey53" => [135, 135, 135],
|
509
|
+
"grey52" => [133, 133, 133],
|
510
|
+
"grey51" => [130, 130, 130],
|
511
|
+
"fractal" => [128, 128, 128],
|
512
|
+
"grey50" => [127, 127, 127],
|
513
|
+
"grey49" => [125, 125, 125],
|
514
|
+
"grey48" => [122, 122, 122],
|
515
|
+
"grey47" => [120, 120, 120],
|
516
|
+
"grey46" => [117, 117, 117],
|
517
|
+
"grey45" => [115, 115, 115],
|
518
|
+
"grey44" => [112, 112, 112],
|
519
|
+
"grey43" => [110, 110, 110],
|
520
|
+
"grey42" => [107, 107, 107],
|
521
|
+
"dimgrey" => [105, 105, 105],
|
522
|
+
"grey41" => [105, 105, 105],
|
523
|
+
"grey40" => [102, 102, 102],
|
524
|
+
"grey39" => [ 99, 99, 99],
|
525
|
+
"grey38" => [ 97, 97, 97],
|
526
|
+
"grey37" => [ 94, 94, 94],
|
527
|
+
"grey36" => [ 92, 92, 92],
|
528
|
+
"grey35" => [ 89, 89, 89],
|
529
|
+
"grey34" => [ 87, 87, 87],
|
530
|
+
"grey33" => [ 84, 84, 84],
|
531
|
+
"grey32" => [ 82, 82, 82],
|
532
|
+
"grey31" => [ 79, 79, 79],
|
533
|
+
"grey30" => [ 77, 77, 77],
|
534
|
+
"grey29" => [ 74, 74, 74],
|
535
|
+
"grey28" => [ 71, 71, 71],
|
536
|
+
"grey27" => [ 69, 69, 69],
|
537
|
+
"grey26" => [ 66, 66, 66],
|
538
|
+
"grey25" => [ 64, 64, 64],
|
539
|
+
"grey24" => [ 61, 61, 61],
|
540
|
+
"grey23" => [ 59, 59, 59],
|
541
|
+
"grey22" => [ 56, 56, 56],
|
542
|
+
"grey21" => [ 54, 54, 54],
|
543
|
+
"grey20" => [ 51, 51, 51],
|
544
|
+
"grey19" => [ 48, 48, 48],
|
545
|
+
"grey18" => [ 46, 46, 46],
|
546
|
+
"grey17" => [ 43, 43, 43],
|
547
|
+
"grey16" => [ 41, 41, 41],
|
548
|
+
"grey15" => [ 38, 38, 38],
|
549
|
+
"grey14" => [ 36, 36, 36],
|
550
|
+
"grey13" => [ 33, 33, 33],
|
551
|
+
"grey12" => [ 31, 31, 31],
|
552
|
+
"grey11" => [ 28, 28, 28],
|
553
|
+
"grey10" => [ 26, 26, 26],
|
554
|
+
"grey9" => [ 23, 23, 23],
|
555
|
+
"grey8" => [ 20, 20, 20],
|
556
|
+
"grey7" => [ 18, 18, 18],
|
557
|
+
"grey6" => [ 15, 15, 15],
|
558
|
+
"grey5" => [ 13, 13, 13],
|
559
|
+
"grey4" => [ 10, 10, 10],
|
560
|
+
"grey3" => [ 8, 8, 8],
|
561
|
+
"grey2" => [ 5, 5, 5],
|
562
|
+
"grey1" => [ 3, 3, 3],
|
563
|
+
"black" => [ 0, 0, 0],
|
564
|
+
"grey0" => [ 0, 0, 0],
|
565
|
+
"opaque" => [ 0, 0, 0],
|
566
|
+
"transparent" => [0, 0, 0]
|
567
|
+
}
|
568
|
+
|
569
|
+
module_function
|
570
|
+
|
571
|
+
def get(name)
|
572
|
+
return name if name.is_a?(Array)
|
573
|
+
|
574
|
+
MAPPING.fetch(normalize(name))
|
575
|
+
rescue KeyError
|
576
|
+
raise Error, "unknown color name: #{name.inspect}"
|
577
|
+
end
|
578
|
+
|
579
|
+
def normalize(name)
|
580
|
+
name.downcase.sub("gray", "grey")
|
581
|
+
end
|
582
|
+
end
|
583
|
+
end
|
584
|
+
end
|