module CarrierWave::Color::Detection

Public Instance Methods

dominant_from_palette_html(path, palette_hexes) click to toggle source
# File lib/carrierwave/color/detection.rb, line 14
def dominant_from_palette_html(path, palette_hexes)
  scores = Colorscore::Histogram.new(path).scores
  palette = Colorscore::Palette.from_hex(palette_hexes)

  # Return nil values from scores
  scores.reject! { |_color_score, color| color.nil? }
  return nil if scores.empty?

  scores = palette.scores(scores, 1)
  _score, color = scores.first
  color.html
end
dominant_html(path) click to toggle source
# File lib/carrierwave/color/detection.rb, line 8
def dominant_html(path)
  histogram = Colorscore::Histogram.new(path, 1)
  color = histogram.colors.first
  color && color.html
end