imagga 0.0.2 → 0.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/README.md CHANGED
@@ -32,6 +32,7 @@ Extract image information
32
32
 
33
33
  results = client.extract('http://imagga.com/images/scheme_colors.png')
34
34
 
35
+
35
36
  Extract image information with indexing and extraction options:
36
37
 
37
38
  results = client.extract(
@@ -43,6 +44,25 @@ Extract image information with indexing and extraction options:
43
44
  extract_object_colors: false
44
45
  )
45
46
 
47
+ Check the results, for example:
48
+
49
+ results.each do |info| # iterate over all input image infos
50
+ puts info.object_percentage # percentage of the central object on image
51
+ info.image_colors.each do |color| # iterate over all significant colors
52
+ puts color.info # 85.89%, rgb: (246,246,246), hex: #f6f6f6
53
+ end
54
+ end
55
+
56
+ Multi-color search:
57
+
58
+ client.rank(
59
+ color_vector: '20,82,37,43,30,20,30,10', # vector of colors (percentage, r, g, b)
60
+ type: 'object',
61
+ dist: 6000,
62
+ count: 10
63
+ ).each do |similarity|
64
+ puts "Distance of #%i is %.4f" % [similarity.id, similarity.dist] # Distance of #333 is 3581.5500
65
+ end
46
66
 
47
67
  ## Contributing
48
68
 
@@ -59,6 +59,9 @@ module Imagga
59
59
  @percent = value.to_f
60
60
  end
61
61
 
62
+ def info
63
+ "%.2f\%%, rgb: (%i,%i,%i), hex: %s" % [percent, r, g, b, html_code]
64
+ end
62
65
  end
63
66
 
64
67
  class RankSimilarity < ImageInfoBase
@@ -1,3 +1,3 @@
1
1
  module Imagga
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
@@ -11,8 +11,15 @@ describe Imagga::ImageColor do
11
11
  "closest_palette_distance" => 2.03931376316
12
12
  } }
13
13
 
14
+ subject { described_class.new(init_hash) }
15
+
16
+ describe "#info" do
17
+ it "shows overview of the color" do
18
+ subject.info.should == '19.29%, rgb: (174,180,187), hex: #aeb4bb'
19
+ end
20
+ end
21
+
14
22
  describe "initialized by hash" do
15
- subject { described_class.new(init_hash) }
16
23
 
17
24
  it "has percent" do
18
25
  subject.percent.should == 19.29
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: imagga
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-02-22 00:00:00.000000000 Z
12
+ date: 2013-02-23 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: httparty
@@ -137,7 +137,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
137
137
  version: '0'
138
138
  segments:
139
139
  - 0
140
- hash: 440675985594337981
140
+ hash: 1906087538434497145
141
141
  required_rubygems_version: !ruby/object:Gem::Requirement
142
142
  none: false
143
143
  requirements:
@@ -146,7 +146,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
146
146
  version: '0'
147
147
  segments:
148
148
  - 0
149
- hash: 440675985594337981
149
+ hash: 1906087538434497145
150
150
  requirements: []
151
151
  rubyforge_project:
152
152
  rubygems_version: 1.8.25