colorant 0.1.3 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile.lock +1 -3
- data/lib/colorant/processer.rb +1 -1
- data/lib/colorant/reporter.rb +13 -1
- data/lib/colorant/version.rb +1 -1
- data/spec/reporter_spec.rb +2 -4
- metadata +4 -30
data/Gemfile.lock
CHANGED
data/lib/colorant/processer.rb
CHANGED
@@ -17,7 +17,7 @@ module Colorant
|
|
17
17
|
end
|
18
18
|
|
19
19
|
def process!
|
20
|
-
raw_data = `convert #{file} -format %c -colors #{colors} -depth #{depth} histogram:info:- | sort -r -k 1`
|
20
|
+
raw_data = `convert #{file} -gravity Center -crop 80x60% +repage -format %c -colors #{colors} -depth #{depth} histogram:info:- | sort -r -k 1`
|
21
21
|
@data = Parser.parse(raw_data)
|
22
22
|
Reporter.report(@data, @reporter_options)
|
23
23
|
end
|
data/lib/colorant/reporter.rb
CHANGED
@@ -19,7 +19,19 @@ module Colorant
|
|
19
19
|
[color.last, row[:freq]]
|
20
20
|
end
|
21
21
|
end
|
22
|
-
|
22
|
+
|
23
|
+
freqs = {}
|
24
|
+
data.each do |color|
|
25
|
+
if freqs[color[0]]
|
26
|
+
freqs[color[0]] += color[1]
|
27
|
+
else
|
28
|
+
freqs[color[0]] = color[1]
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
colors = freqs.to_a.sort{|a, b| b[1] <=> a[1]}
|
33
|
+
|
34
|
+
send(:"#{options[:reporter] || :ruby}_report", colors)
|
23
35
|
end
|
24
36
|
|
25
37
|
private
|
data/lib/colorant/version.rb
CHANGED
data/spec/reporter_spec.rb
CHANGED
@@ -31,8 +31,7 @@ module Colorant
|
|
31
31
|
describe "#report" do
|
32
32
|
|
33
33
|
it 'outputs a simple ordered array with the image color composition' do
|
34
|
-
subject.report(arnolfini_data).should == [["Brown",
|
35
|
-
["Brown", 29.35]]
|
34
|
+
subject.report(arnolfini_data).should == [["Brown", 100]]
|
36
35
|
end
|
37
36
|
|
38
37
|
context "when called with :extended => true" do
|
@@ -60,8 +59,7 @@ module Colorant
|
|
60
59
|
|
61
60
|
it 'outputs a simple ordered array with the image color composition' do
|
62
61
|
subject.report(arnolfini_data, :reporter => :stdout)
|
63
|
-
@out.string.should include "\tBrown\t\t\t\t\t\t--
|
64
|
-
@out.string.should include "\tBrown\t\t\t\t\t\t-- 29.35 %\n"
|
62
|
+
@out.string.should include "\tBrown\t\t\t\t\t\t-- 100.0 %\n"
|
65
63
|
end
|
66
64
|
|
67
65
|
context "when called with :extended => true" do
|
metadata
CHANGED
@@ -1,12 +1,8 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: colorant
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
prerelease:
|
5
|
-
|
6
|
-
- 0
|
7
|
-
- 1
|
8
|
-
- 3
|
9
|
-
version: 0.1.3
|
4
|
+
prerelease:
|
5
|
+
version: 0.1.4
|
10
6
|
platform: ruby
|
11
7
|
authors:
|
12
8
|
- Josep M. Bach
|
@@ -16,7 +12,7 @@ autorequire:
|
|
16
12
|
bindir: bin
|
17
13
|
cert_chain: []
|
18
14
|
|
19
|
-
date:
|
15
|
+
date: 2011-04-16 00:00:00 +02:00
|
20
16
|
default_executable:
|
21
17
|
dependencies:
|
22
18
|
- !ruby/object:Gem::Dependency
|
@@ -27,8 +23,6 @@ dependencies:
|
|
27
23
|
requirements:
|
28
24
|
- - ">="
|
29
25
|
- !ruby/object:Gem::Version
|
30
|
-
segments:
|
31
|
-
- 0
|
32
26
|
version: "0"
|
33
27
|
type: :runtime
|
34
28
|
version_requirements: *id001
|
@@ -40,8 +34,6 @@ dependencies:
|
|
40
34
|
requirements:
|
41
35
|
- - ">="
|
42
36
|
- !ruby/object:Gem::Version
|
43
|
-
segments:
|
44
|
-
- 0
|
45
37
|
version: "0"
|
46
38
|
type: :runtime
|
47
39
|
version_requirements: *id002
|
@@ -53,10 +45,6 @@ dependencies:
|
|
53
45
|
requirements:
|
54
46
|
- - ">="
|
55
47
|
- !ruby/object:Gem::Version
|
56
|
-
segments:
|
57
|
-
- 1
|
58
|
-
- 0
|
59
|
-
- 3
|
60
48
|
version: 1.0.3
|
61
49
|
type: :development
|
62
50
|
version_requirements: *id003
|
@@ -68,8 +56,6 @@ dependencies:
|
|
68
56
|
requirements:
|
69
57
|
- - ">="
|
70
58
|
- !ruby/object:Gem::Version
|
71
|
-
segments:
|
72
|
-
- 0
|
73
59
|
version: "0"
|
74
60
|
type: :development
|
75
61
|
version_requirements: *id004
|
@@ -81,8 +67,6 @@ dependencies:
|
|
81
67
|
requirements:
|
82
68
|
- - ">="
|
83
69
|
- !ruby/object:Gem::Version
|
84
|
-
segments:
|
85
|
-
- 0
|
86
70
|
version: "0"
|
87
71
|
type: :development
|
88
72
|
version_requirements: *id005
|
@@ -94,8 +78,6 @@ dependencies:
|
|
94
78
|
requirements:
|
95
79
|
- - ">="
|
96
80
|
- !ruby/object:Gem::Version
|
97
|
-
segments:
|
98
|
-
- 0
|
99
81
|
version: "0"
|
100
82
|
type: :development
|
101
83
|
version_requirements: *id006
|
@@ -107,8 +89,6 @@ dependencies:
|
|
107
89
|
requirements:
|
108
90
|
- - ">="
|
109
91
|
- !ruby/object:Gem::Version
|
110
|
-
segments:
|
111
|
-
- 0
|
112
92
|
version: "0"
|
113
93
|
type: :development
|
114
94
|
version_requirements: *id007
|
@@ -158,23 +138,17 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
158
138
|
requirements:
|
159
139
|
- - ">="
|
160
140
|
- !ruby/object:Gem::Version
|
161
|
-
segments:
|
162
|
-
- 0
|
163
141
|
version: "0"
|
164
142
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
165
143
|
none: false
|
166
144
|
requirements:
|
167
145
|
- - ">="
|
168
146
|
- !ruby/object:Gem::Version
|
169
|
-
segments:
|
170
|
-
- 1
|
171
|
-
- 3
|
172
|
-
- 6
|
173
147
|
version: 1.3.6
|
174
148
|
requirements: []
|
175
149
|
|
176
150
|
rubyforge_project: colorant
|
177
|
-
rubygems_version: 1.
|
151
|
+
rubygems_version: 1.6.2
|
178
152
|
signing_key:
|
179
153
|
specification_version: 3
|
180
154
|
summary: Easily extract the colors of any image file!
|