jnylen-colorscore 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 41850e99437a7328d6e7edc19576b2d1776077db
4
- data.tar.gz: 828d20cbb163ed24b648c8cd0e85f49fffc9f0e0
3
+ metadata.gz: a8c814223d7b429f76b6b62d53fbe3be2e5a42d3
4
+ data.tar.gz: 46ccd43cf3c9b432366c2ea42904e4b8780fa549
5
5
  SHA512:
6
- metadata.gz: 92c4e8f29715442f4899cb0cbb6913d3702f7a8374b3dd293227064d2c1b921259583600822dce56ec90ea21e8f016e9156b1eba1467afe83f85358c24654b0d
7
- data.tar.gz: 6d4b95007e931d211f18d2855ccc25345e291acbe8302fc78312c7f69ff098d4ec4e3701f101390532060c004988909af4fea01c47210a375f20ef8472e96542
6
+ metadata.gz: ff4b836aa50ea6697793be254d12e0c98856b311ee1f69f6eec11b0069649b464d1f360b466c2e77a5714bc3b6ffb34d31329e628b52088405e7244371fd378e
7
+ data.tar.gz: 60b82f50750ef6e663f849874b53086c8ba7144b38a6a0e814f2d0834a8b0148d2556639372e6f7bff74cfcfea9d4271f86391d931e23a76260ba5c58345dd8a
data/README.md CHANGED
@@ -1,5 +1,3 @@
1
- Major change from normal colorscore: .colors is .hex_colors.
2
-
3
1
  # Colorscore
4
2
 
5
3
  Colorscore is a simple library that uses ImageMagick to quantize an image and find its representative colors. It can also score those colors against a palette using the CIE2000 Delta E formula. This could be used to index images for a "search by color" feature.
@@ -21,15 +21,11 @@ module Colorscore
21
21
  end
22
22
 
23
23
  # Returns an array of colors in descending order of occurances.
24
- def hex_colors
24
+ def colors
25
25
  hex_values = @lines.map { |line| line[/#([0-9A-F]{6}) /, 1] }.compact
26
26
  hex_values.map { |hex| Color::RGB.from_html(hex) }
27
27
  end
28
28
 
29
- def rgb_colors
30
- @lines.map { |line| line[/ \(([0-9, ]+)\) /, 1].split(',').map(&:strip).take(3).join(',') }.compact
31
- end
32
-
33
29
  def color_counts
34
30
  @lines.map { |line| line.split(':')[0].to_i }
35
31
  end
@@ -37,7 +33,7 @@ module Colorscore
37
33
  def scores
38
34
  total = color_counts.inject(:+).to_f
39
35
  scores = color_counts.map { |count| count / total }
40
- scores.zip(hex_colors)
36
+ scores.zip(colors)
41
37
  end
42
38
  end
43
39
  end
@@ -1,3 +1,3 @@
1
1
  module Colorscore
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  end
@@ -4,11 +4,11 @@ class HistogramTest < Test::Unit::TestCase
4
4
  def test_color_count_is_correct
5
5
  colors = 7
6
6
  histogram = Histogram.new("test/fixtures/skydiver.jpg", :colors => colors)
7
- assert_operator histogram.hex_colors.size, :<=, colors
7
+ assert_operator histogram.colors.size, :<=, colors
8
8
  end
9
9
 
10
10
  def test_transparency_is_ignored
11
11
  histogram = Histogram.new("test/fixtures/transparency.png")
12
- assert_equal Color::RGB.from_html('0000ff'), histogram.hex_colors.first
12
+ assert_equal Color::RGB.from_html('0000ff'), histogram.colors.first
13
13
  end
14
14
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jnylen-colorscore
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joakim Nylén