miro 0.2.1 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/miro.rb +2 -1
- data/lib/miro/dominant_colors.rb +9 -10
- data/lib/miro/version.rb +1 -1
- data/spec/miro/dominant_colors_spec.rb +8 -5
- metadata +32 -11
data/lib/miro.rb
CHANGED
data/lib/miro/dominant_colors.rb
CHANGED
@@ -17,7 +17,7 @@ module Miro
|
|
17
17
|
def to_rgba
|
18
18
|
sorted_pixels.collect {|c| ChunkyPNG::Color.to_truecolor_alpha_bytes c }
|
19
19
|
end
|
20
|
-
|
20
|
+
|
21
21
|
def by_percentage
|
22
22
|
sorted_pixels
|
23
23
|
pixel_count = @pixels.size
|
@@ -43,25 +43,24 @@ module Miro
|
|
43
43
|
def downsample_colors_and_convert_to_png!
|
44
44
|
@source_image = open_source_image
|
45
45
|
@downsampled_image = open_downsampled_image
|
46
|
-
command.run
|
47
|
-
end
|
48
46
|
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
47
|
+
Cocaine::CommandLine.new(Miro.options[:image_magick_path], "':in[0]' -resize :resolution -colors :colors -colorspace :quantize -quantize :quantize :out").
|
48
|
+
run(:in => File.expand_path(@source_image.path),
|
49
|
+
:resolution => Miro.options[:resolution],
|
50
|
+
:colors => Miro.options[:color_count].to_s,
|
51
|
+
:quantize => Miro.options[:quantize],
|
52
|
+
:out => File.expand_path(@downsampled_image.path))
|
55
53
|
end
|
56
54
|
|
57
55
|
def open_source_image
|
58
56
|
if remote_source_image?
|
59
57
|
original_extension = URI.parse(@src_image_path).path.split('.').last
|
60
|
-
|
58
|
+
|
61
59
|
tempfile = Tempfile.open(["source", ".#{original_extension}"])
|
62
60
|
remote_file_data = open(@src_image_path).read
|
63
61
|
|
64
62
|
tempfile.write(RUBY_VERSION =~ /1.9/ ? remote_file_data.force_encoding("UTF-8") : remote_file_data)
|
63
|
+
tempfile.close
|
65
64
|
return tempfile
|
66
65
|
else
|
67
66
|
return File.open(@src_image_path)
|
data/lib/miro/version.rb
CHANGED
@@ -56,12 +56,15 @@ describe Miro::DominantColors do
|
|
56
56
|
|
57
57
|
it "runs the imagemagick command line with the correct arguments" do
|
58
58
|
subject.stub(:open_downsampled_image).and_return(mock_downsampled_image)
|
59
|
+
line = double('line')
|
59
60
|
Cocaine::CommandLine.should_receive(:new).with(Miro.options[:image_magick_path],
|
60
|
-
":in -resize :resolution -colors :colors :out"
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
61
|
+
"':in[0]' -resize :resolution -colors :colors -colorspace :quantize -quantize :quantize :out").and_return(line)
|
62
|
+
|
63
|
+
line.should_receive(:run).with(:in => '/path/to/source_image',
|
64
|
+
:resolution => Miro.options[:resolution],
|
65
|
+
:colors => Miro.options[:color_count].to_s,
|
66
|
+
:quantize => Miro.options[:quantize],
|
67
|
+
:out => '/path/to/downsampled_image')
|
65
68
|
subject.sorted_pixels
|
66
69
|
end
|
67
70
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: miro
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-12-04 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: cocaine
|
16
|
-
requirement:
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,15 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements:
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
25
30
|
- !ruby/object:Gem::Dependency
|
26
31
|
name: oily_png
|
27
|
-
requirement:
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
28
33
|
none: false
|
29
34
|
requirements:
|
30
35
|
- - ! '>='
|
@@ -32,10 +37,15 @@ dependencies:
|
|
32
37
|
version: '0'
|
33
38
|
type: :runtime
|
34
39
|
prerelease: false
|
35
|
-
version_requirements:
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
36
46
|
- !ruby/object:Gem::Dependency
|
37
47
|
name: rspec
|
38
|
-
requirement:
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
39
49
|
none: false
|
40
50
|
requirements:
|
41
51
|
- - ! '>='
|
@@ -43,10 +53,15 @@ dependencies:
|
|
43
53
|
version: '0'
|
44
54
|
type: :development
|
45
55
|
prerelease: false
|
46
|
-
version_requirements:
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
47
62
|
- !ruby/object:Gem::Dependency
|
48
63
|
name: fakeweb
|
49
|
-
requirement:
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
50
65
|
none: false
|
51
66
|
requirements:
|
52
67
|
- - ! '>='
|
@@ -54,7 +69,12 @@ dependencies:
|
|
54
69
|
version: '0'
|
55
70
|
type: :development
|
56
71
|
prerelease: false
|
57
|
-
version_requirements:
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ! '>='
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0'
|
58
78
|
description: Extract the dominant colors from an image.
|
59
79
|
email:
|
60
80
|
- jon.buda@gmail.com
|
@@ -96,7 +116,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
96
116
|
requirements:
|
97
117
|
- ImageMagick
|
98
118
|
rubyforge_project:
|
99
|
-
rubygems_version: 1.8.
|
119
|
+
rubygems_version: 1.8.23
|
100
120
|
signing_key:
|
101
121
|
specification_version: 3
|
102
122
|
summary: Extract the dominant colors from an image.
|
@@ -104,3 +124,4 @@ test_files:
|
|
104
124
|
- spec/miro/dominant_colors_spec.rb
|
105
125
|
- spec/miro_spec.rb
|
106
126
|
- spec/spec_helper.rb
|
127
|
+
has_rdoc:
|