falu 0.0.7 → 0.0.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/falu/image.rb +10 -0
- data/lib/falu/image_palette.rb +9 -4
- data/lib/falu/version.rb +1 -1
- metadata +3 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8b235276bb176363e82d734e4fab0ac1efaa229e
|
4
|
+
data.tar.gz: e01a8adc24c2d3043ca00ba5610190100124f1e2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ccfc93f0732d4d85d1d41301bb2a8b0778fe46940e120bd144398bd95e4d8942d689dcace96f18a9118ec85568612382a7d0be6543f27d0d2c6c9316a25ae1f0
|
7
|
+
data.tar.gz: ab7cf7d35a5d87b2f11ceab4c2d5777f10984bd78720ae6aa3370124fddad4c63f489d7a3f78297d3370b114ca10774acc82c46b0b6bb9c9a19c8883103fab51
|
data/lib/falu/image.rb
CHANGED
@@ -15,6 +15,7 @@ module Falu
|
|
15
15
|
delegate :width, :height, :path, :run_command, to: :image
|
16
16
|
|
17
17
|
def initialize(image)
|
18
|
+
@raw_image = image
|
18
19
|
@image = image
|
19
20
|
end
|
20
21
|
|
@@ -88,6 +89,15 @@ module Falu
|
|
88
89
|
palette.to_a.to_enum
|
89
90
|
end
|
90
91
|
|
92
|
+
def miro
|
93
|
+
colors = Miro::DominantColors.new(@raw_image)
|
94
|
+
hex = colors.to_hex
|
95
|
+
pct = colors.by_percentage
|
96
|
+
hex.each_with_index.map do |clr,idx|
|
97
|
+
[clr, pct[idx] * 100]
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
91
101
|
def scale(scale, filename: nil)
|
92
102
|
filename ||= Tempfile.new(['scaled', '.png']).path
|
93
103
|
|
data/lib/falu/image_palette.rb
CHANGED
@@ -12,10 +12,10 @@ module Falu
|
|
12
12
|
end
|
13
13
|
end
|
14
14
|
|
15
|
-
delegate :sample, :scale, :size, to: :configuration
|
15
|
+
delegate :sample, :scale, :size, :miro, to: :configuration
|
16
16
|
|
17
17
|
def initialize(image, swatches=nil, **opts)
|
18
|
-
configuration.configure({sample: nil, scale: 500, size: 10})
|
18
|
+
configuration.configure({sample: nil, scale: 500, size: 10, miro: false})
|
19
19
|
super(swatches, **opts)
|
20
20
|
@image = image
|
21
21
|
end
|
@@ -26,7 +26,11 @@ module Falu
|
|
26
26
|
end
|
27
27
|
|
28
28
|
def swatches
|
29
|
-
|
29
|
+
if miro
|
30
|
+
@swatches = image.miro.map { |swatch| Falu::Swatch.new(*swatch) } if @swatches.empty?
|
31
|
+
else
|
32
|
+
@swatches = image.scale(scale).sample(0, 0, size: size, sample: sample).map { |swatch| Falu::Swatch.new(*swatch) } if @swatches.empty?
|
33
|
+
end
|
30
34
|
@swatches
|
31
35
|
end
|
32
36
|
|
@@ -34,7 +38,8 @@ module Falu
|
|
34
38
|
super(options).merge({
|
35
39
|
sample: sample,
|
36
40
|
scale: scale,
|
37
|
-
size: size
|
41
|
+
size: size,
|
42
|
+
miro: miro
|
38
43
|
})
|
39
44
|
end
|
40
45
|
end
|
data/lib/falu/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: falu
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mark Rebec
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-11-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: canfig
|
@@ -120,10 +120,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
120
120
|
version: '0'
|
121
121
|
requirements: []
|
122
122
|
rubyforge_project:
|
123
|
-
rubygems_version: 2.
|
123
|
+
rubygems_version: 2.6.13
|
124
124
|
signing_key:
|
125
125
|
specification_version: 4
|
126
126
|
summary: Extract color swatches from images with imagemagick
|
127
127
|
test_files:
|
128
128
|
- spec/spec_helper.rb
|
129
|
-
has_rdoc:
|