Hello there,
I want to extract the dominant color from an array of images. I’ve tried several formulas with no success and at this point I found a gem called Miro, but it seems I’m missing something. I’ve bundled it to my project and then I defined a helper method in my config.rb:
def dom_colr(img)
Miro.options[:color_count] = 1
Miro.options[:method] = 'histogram'
colors = Miro::DominantColors.new('img')
end
In my html.erb I made a loop that looks like this:
<ul class="list--thumbs">
<% data['works']['images'].each_with_index do |s| %>
<li class="item--thumb" style="background-color: <%= dom_colr(s) %>;">
<% link_to(s, {:class=>'thumb__link', :target=>'_blank'}) do %>
<%= image_tag(s, {:class=>'thumb__img', :resize_to=>'360x360'}) %>
<% end %>
</li>
<% end %>
</ul>
The result my browser prints is something like this:
<li class="item--thumb" style="background-color: #<Miro::DominantColors:0x007fdc5d571368>;">
I’m new to Ruby and my lack of basic knowledge is mirrored in the above, but I would apreciate any kind of help.
Thanks in advance!