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 +4 -4
- data/lib/ffi/gmagick/image.rb +5 -2
- data/lib/ffi/gmagick/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6cd0e82c18ae40fdac196a30427d057c0d7ef6c4
|
4
|
+
data.tar.gz: 8c5ecdd6bb78c1e3bb5186b9a69370d1036fe8ba
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fadf91e22cac1576821a48d0f5b3b71984a2c5f7e81f2f247cde323f87896db0add2eba15e2177b8d94b6058051860a0313a6011136ae79252f18094d2bb5af3
|
7
|
+
data.tar.gz: 69ec4bc5171084bdca4856083e5057e679bc8626c7842cf7af3a8ebbfc3f5c1457b1a691ee112402136e17d253f005e2e82335c2625d11819c08b59ebd5ad462
|
data/lib/ffi/gmagick/image.rb
CHANGED
@@ -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
|
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
|
-
|
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
|
data/lib/ffi/gmagick/version.rb
CHANGED