rmagick-image_colors 0.1.0 → 0.1.1

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 06412df0aaa6381741d700663e7d92dfb0c98f5c
4
- data.tar.gz: dc75393dfc7187ba9658307cc1861eb81712a22a
3
+ metadata.gz: 2f8a4f9337ab4c384fd526c577232638a79a9670
4
+ data.tar.gz: 76143c368cff08247184ce34b5c9aa7dab1e27cf
5
5
  SHA512:
6
- metadata.gz: 17d9f5de9dabbf61d4b9420704e2efc3268548160b9a3842db603a0924f2cdc3edaadae278fa3bba2541b4b5b2ac7f5de5458903dbb0dbc099b17edad0ca58ad
7
- data.tar.gz: ae853ecd406c1ddd6a0eb579396383094c69d877dce82761f08c902aadd4cd539ed41815225f5910040fae645febfe145510b814ed4c056ac365fd01c025698b
6
+ metadata.gz: 4cd3bc09c4b6c09fb5dd543f0aeca3db305068cdca6b0caacf9c2bb32341c2f1052e3fc8e04a50e5c064e53087e90b02d1740bae3a0a52c8fbe06a86c467a2af
7
+ data.tar.gz: cbd84dd404bc94afc6c689957b5974400c83b3df9da9c409dd4bc8e227db02b66f5e9054919c433025657822b74aa7e45835b5ef6c68d16346ea2fce9760463d
data/bin/console CHANGED
File without changes
data/bin/setup CHANGED
File without changes
@@ -1,5 +1,5 @@
1
1
  module Magick
2
2
  class ImageColors
3
- VERSION = "0.1.0"
3
+ VERSION = "0.1.1"
4
4
  end
5
5
  end
@@ -19,18 +19,20 @@ module Magick
19
19
 
20
20
  private
21
21
  def aggregate(&block)
22
- colors = {}
23
22
  depth = @image.depth
24
- @image.color_histogram.each do |pixel|
25
- if block_given?
26
- color = block.call(pixel)
27
- else
28
- color = pixel[0].to_color(Magick::AllCompliance, false, depth, true)
29
- end
30
- colors[color] ||= 0
31
- colors[color] += pixel[1]
32
- end
33
- @colors = colors.sort{|a, b| b[1] <=> a[1]}
23
+ @colors = @image.color_histogram.inject({}) do |colors, pixel|
24
+ color = if block_given?
25
+ block.call(pixel, depth)
26
+ else
27
+ pixel[0].to_color(Magick::AllCompliance, false, depth, true)
28
+ end
29
+
30
+ next if color.nil?
31
+
32
+ colors[color] ||= 0
33
+ colors[color] += pixel[1]
34
+ colors
35
+ end.sort{|a, b| b[1] <=> a[1]}
34
36
  end
35
37
  end
36
38
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rmagick-image_colors
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - shiro16