shrine-color 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.travis.yml +7 -0
- data/Gemfile.lock +8 -8
- data/README.md +4 -2
- data/lib/shrine/plugins/color.rb +2 -3
- data/shrine-color.gemspec +3 -3
- data/spec/shrine/color_spec.rb +20 -5
- metadata +14 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 2023aa78c934dff3cc608b6ee525b79ec8e2a2ab34b0eb10c9714cb59155b358
|
4
|
+
data.tar.gz: 1af9151c8c4f44fcb06eee37583ea68490ec47096ae4fc8d74f35ec5a4daba00
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fffa4367e60af3be0ef9c67b4b08acbe9fa2571498f664931e7a43ee36f878175527819ebd4566c479c07ca96aa0ff04cc8e393d3ab8d144984776dc34c03618
|
7
|
+
data.tar.gz: bbebd1fe938f8bf4a53b447989c1403bfb49423eaa0ba7692f5cef29fdfed5aab86a3377e135e9e5dd35cbecdada9048def46fa5f007378648ca14f9fac1732a
|
data/.travis.yml
ADDED
data/Gemfile.lock
CHANGED
@@ -1,17 +1,17 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
shrine-color (0.
|
5
|
-
jnylen-colorscore (>= 0.1.
|
6
|
-
shrine (
|
4
|
+
shrine-color (0.3.0)
|
5
|
+
jnylen-colorscore (~> 0.1, >= 0.1.3)
|
6
|
+
shrine (~> 2.0)
|
7
7
|
|
8
8
|
GEM
|
9
9
|
remote: https://rubygems.org/
|
10
10
|
specs:
|
11
11
|
color (1.8)
|
12
12
|
diff-lcs (1.2.5)
|
13
|
-
down (
|
14
|
-
jnylen-colorscore (0.1.
|
13
|
+
down (4.5.0)
|
14
|
+
jnylen-colorscore (0.1.3)
|
15
15
|
color
|
16
16
|
rake (11.2.2)
|
17
17
|
rspec (3.5.0)
|
@@ -27,8 +27,8 @@ GEM
|
|
27
27
|
diff-lcs (>= 1.2.0, < 2.0)
|
28
28
|
rspec-support (~> 3.5.0)
|
29
29
|
rspec-support (3.5.0)
|
30
|
-
shrine (2.
|
31
|
-
down (
|
30
|
+
shrine (2.11.0)
|
31
|
+
down (~> 4.1)
|
32
32
|
|
33
33
|
PLATFORMS
|
34
34
|
ruby
|
@@ -40,4 +40,4 @@ DEPENDENCIES
|
|
40
40
|
shrine-color!
|
41
41
|
|
42
42
|
BUNDLED WITH
|
43
|
-
1.
|
43
|
+
1.16.2
|
data/README.md
CHANGED
@@ -5,6 +5,8 @@ Get the dominant color of an image using colorscore (updated version by me). Thi
|
|
5
5
|
|
6
6
|
This is based on carrierwave-color by Sunny Ripert (sunny).
|
7
7
|
|
8
|
+
NOTE: The palettes/dominiant_color grabbed from images may differ between imagemagick versions.
|
9
|
+
|
8
10
|
Requirements
|
9
11
|
------------
|
10
12
|
|
@@ -43,10 +45,10 @@ class ImageUploader < Shrine
|
|
43
45
|
dominant_color(io.path)
|
44
46
|
end
|
45
47
|
|
46
|
-
# palette color with version and own array of colors.
|
48
|
+
# palette color with version, color count and own array of colors.
|
47
49
|
add_metadata :palette_color do |io, context|
|
48
50
|
if context[:version] == :small
|
49
|
-
palette_color(io.path, ['ff0000', '00ff00', '0000ff'])
|
51
|
+
palette_color(io.path, 3, ['ff0000', '00ff00', '0000ff'])
|
50
52
|
end
|
51
53
|
end
|
52
54
|
end
|
data/lib/shrine/plugins/color.rb
CHANGED
@@ -23,7 +23,7 @@ class Shrine
|
|
23
23
|
end
|
24
24
|
|
25
25
|
# Matches the dominant color to the closest color in the array provided
|
26
|
-
def palette_color(io_path, palette_hexes = DEFAULT_PALETTE_HEXES)
|
26
|
+
def palette_color(io_path, color_count = 1, palette_hexes = DEFAULT_PALETTE_HEXES)
|
27
27
|
histogram = Colorscore::Histogram.new(io_path)
|
28
28
|
palette = Colorscore::Palette.from_hex(palette_hexes)
|
29
29
|
|
@@ -31,8 +31,7 @@ class Shrine
|
|
31
31
|
return nil if histogram_scores.first.last.nil?
|
32
32
|
|
33
33
|
scores = palette.scores(histogram_scores, 1)
|
34
|
-
_score, color
|
35
|
-
color.html
|
34
|
+
scores.first(color_count).map { |_score, color| color.html}
|
36
35
|
end
|
37
36
|
|
38
37
|
end
|
data/shrine-color.gemspec
CHANGED
@@ -3,7 +3,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
3
3
|
|
4
4
|
Gem::Specification.new do |spec|
|
5
5
|
spec.name = "shrine-color"
|
6
|
-
spec.version = "0.
|
6
|
+
spec.version = "0.3.0"
|
7
7
|
spec.authors = ["Joakim Nylen"]
|
8
8
|
spec.email = ["me@jnylen.nu"]
|
9
9
|
spec.summary = "Return the dominant color of an image in Shrine."
|
@@ -14,8 +14,8 @@ Gem::Specification.new do |spec|
|
|
14
14
|
spec.files = `git ls-files -z`.split("\x0")
|
15
15
|
spec.require_paths = ["lib"]
|
16
16
|
|
17
|
-
spec.add_dependency "shrine", "
|
18
|
-
spec.add_dependency "jnylen-colorscore", ">= 0.1.
|
17
|
+
spec.add_dependency "shrine", "~> 2.0"
|
18
|
+
spec.add_dependency "jnylen-colorscore", "~> 0.1", ">= 0.1.3"
|
19
19
|
|
20
20
|
spec.add_development_dependency "bundler", "~> 1.12"
|
21
21
|
spec.add_development_dependency "rake", "~> 11.1"
|
data/spec/shrine/color_spec.rb
CHANGED
@@ -2,14 +2,17 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe Shrine::Plugins::Color do
|
4
4
|
before do
|
5
|
-
@uploader = uploader {
|
5
|
+
@uploader = uploader {
|
6
|
+
plugin :determine_mime_type
|
7
|
+
plugin :color
|
8
|
+
}
|
6
9
|
end
|
7
10
|
|
8
11
|
describe ":dominant_color" do
|
9
12
|
it "extracts dominant_color from files via add_metadata" do
|
10
13
|
@uploader.class.add_metadata(:dominant_color) { |io, context| dominant_color(io.path) }
|
11
14
|
uploaded_file = @uploader.upload(File.open("spec/fixtures/bora.jpg"))
|
12
|
-
expect(uploaded_file.metadata.fetch("dominant_color")).to eq("#
|
15
|
+
expect(uploaded_file.metadata.fetch("dominant_color")).to eq("#5c97a7")
|
13
16
|
end
|
14
17
|
end
|
15
18
|
|
@@ -17,13 +20,25 @@ describe Shrine::Plugins::Color do
|
|
17
20
|
it "extracts palette_color from files with default hexes via add_metadata" do
|
18
21
|
@uploader.class.add_metadata(:palette_color) { |io, context| palette_color(io.path) }
|
19
22
|
uploaded_file = @uploader.upload(File.open("spec/fixtures/bora.jpg"))
|
20
|
-
expect(uploaded_file.metadata.fetch("palette_color")).to eq("#333399")
|
23
|
+
expect(uploaded_file.metadata.fetch("palette_color")).to eq(["#333399"])
|
21
24
|
end
|
22
25
|
|
23
26
|
it "extracts palette_color from files with custom hexes via add_metadata" do
|
24
|
-
@uploader.class.add_metadata(:palette_color) { |io, context| palette_color(io.path, ['ff0000', '00ff00', '0000ff']) }
|
27
|
+
@uploader.class.add_metadata(:palette_color) { |io, context| palette_color(io.path, 1, ['ff0000', '00ff00', '0000ff']) }
|
25
28
|
uploaded_file = @uploader.upload(File.open("spec/fixtures/bora.jpg"))
|
26
|
-
expect(uploaded_file.metadata.fetch("palette_color")).to eq("#0000ff")
|
29
|
+
expect(uploaded_file.metadata.fetch("palette_color")).to eq(["#0000ff"])
|
30
|
+
end
|
31
|
+
|
32
|
+
it "extracts 3 palette_colors from files with default hexes via add_metadata" do
|
33
|
+
@uploader.class.add_metadata(:palette_color) { |io, context| palette_color(io.path, 3) }
|
34
|
+
uploaded_file = @uploader.upload(File.open("spec/fixtures/bora.jpg"))
|
35
|
+
expect(uploaded_file.metadata.fetch("palette_color")).to eq(["#333399", "#0066cc", "#66cccc"])
|
36
|
+
end
|
37
|
+
|
38
|
+
it "extracts 3 palette_colors from files with custom hexes via add_metadata" do
|
39
|
+
@uploader.class.add_metadata(:palette_color) { |io, context| palette_color(io.path, 3, ['ff0000', '00ff00', '0000ff']) }
|
40
|
+
uploaded_file = @uploader.upload(File.open("spec/fixtures/bora.jpg"))
|
41
|
+
expect(uploaded_file.metadata.fetch("palette_color")).to eq(["#0000ff", "#00ff00"])
|
27
42
|
end
|
28
43
|
end
|
29
44
|
|
metadata
CHANGED
@@ -1,43 +1,49 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: shrine-color
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Joakim Nylen
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-06-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: shrine
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '2.0'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - "
|
24
|
+
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '2.0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: jnylen-colorscore
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0.1'
|
31
34
|
- - ">="
|
32
35
|
- !ruby/object:Gem::Version
|
33
|
-
version: 0.1.
|
36
|
+
version: 0.1.3
|
34
37
|
type: :runtime
|
35
38
|
prerelease: false
|
36
39
|
version_requirements: !ruby/object:Gem::Requirement
|
37
40
|
requirements:
|
41
|
+
- - "~>"
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: '0.1'
|
38
44
|
- - ">="
|
39
45
|
- !ruby/object:Gem::Version
|
40
|
-
version: 0.1.
|
46
|
+
version: 0.1.3
|
41
47
|
- !ruby/object:Gem::Dependency
|
42
48
|
name: bundler
|
43
49
|
requirement: !ruby/object:Gem::Requirement
|
@@ -88,6 +94,7 @@ extensions: []
|
|
88
94
|
extra_rdoc_files: []
|
89
95
|
files:
|
90
96
|
- ".gitignore"
|
97
|
+
- ".travis.yml"
|
91
98
|
- Gemfile
|
92
99
|
- Gemfile.lock
|
93
100
|
- LICENSE
|
@@ -118,7 +125,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
118
125
|
version: '0'
|
119
126
|
requirements: []
|
120
127
|
rubyforge_project:
|
121
|
-
rubygems_version: 2.
|
128
|
+
rubygems_version: 2.7.7
|
122
129
|
signing_key:
|
123
130
|
specification_version: 4
|
124
131
|
summary: Return the dominant color of an image in Shrine.
|