ffi-gmagick 0.0.6 → 0.0.7

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: 59f0ce1781135612f0a2b4e5999184c577f6888e
4
- data.tar.gz: a48984e425cf1f7fff85d7cb518b55c3bdfed9eb
3
+ metadata.gz: 6cd0e82c18ae40fdac196a30427d057c0d7ef6c4
4
+ data.tar.gz: 8c5ecdd6bb78c1e3bb5186b9a69370d1036fe8ba
5
5
  SHA512:
6
- metadata.gz: 5e78df4218cee2fb2f27489910d692e161821c1d286dc1eb3bddcbc74ee72fb1fac2403432d8af4dafd916b69ed496d752770ad902501d6039b4da4bb0c1d5f2
7
- data.tar.gz: 9b16160e80a0269fa9f4f632390765a6539ce90c0abbac76f038dad754e29fa1d99588821a158ccdcd677f525ab4de00cb0e28fb5644176b419e64c0b3b251fd
6
+ metadata.gz: fadf91e22cac1576821a48d0f5b3b71984a2c5f7e81f2f247cde323f87896db0add2eba15e2177b8d94b6058051860a0313a6011136ae79252f18094d2bb5af3
7
+ data.tar.gz: 69ec4bc5171084bdca4856083e5057e679bc8626c7842cf7af3a8ebbfc3f5c1457b1a691ee112402136e17d253f005e2e82335c2625d11819c08b59ebd5ad462
@@ -280,21 +280,24 @@ module FFI
280
280
  end
281
281
 
282
282
  histogram = {}
283
+ total_color_count = 0.0
283
284
  FFI::MemoryPointer.new(:ulong, 1) do |max_colors|
284
285
  pointer = FFI::GMagick.MagickGetImageHistogram( new_wand, max_colors )
285
- number_of_colors = max_colors.read_int
286
+ number_of_colors = max_colors.read_int
286
287
 
287
288
  pixel_wands = pointer.read_array_of_pointer(number_of_colors)
288
289
  pixel_wands.each do |wand|
289
290
  pixel = FFI::GMagick::Pixel.new(wand)
290
291
  hex_color = "#%02X%02X%02X" % pixel.get_color.split(",").map(&:to_i)
291
292
  color_count = pixel.get_color_count
293
+ total_color_count += color_count
292
294
  histogram[hex_color] = color_count
293
295
  end
294
296
  end
295
297
  FFI::GMagick.DestroyMagickWand( new_wand )
296
298
 
297
- return histogram
299
+ # Convert distribution to %
300
+ return histogram.map{|k,v| {k => v / total_color_count}}
298
301
  end
299
302
 
300
303
  # Change the quality (compression) of the image
@@ -1,5 +1,5 @@
1
1
  module FFI
2
2
  module GMagick
3
- VERSION = "0.0.6"
3
+ VERSION = "0.0.7"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ffi-gmagick
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Richard Hurt