Module: ColorExtractor

Defined in:
lib/juice_extractor/core/color_extractor.rb

Defined Under Namespace

Modules: Base

Class Method Summary collapse

Class Method Details

.explicit_colors(site_url, attributes = ['background-color', "border-color", 'color'], quantize = nil) ⇒ Object



10
11
12
13
14
# File 'lib/juice_extractor/core/color_extractor.rb', line 10

def self.explicit_colors(site_url, attributes = ['background-color', "border-color", 'color'], quantize = nil)
  return [] if site_url.nil?
  val = Base.color_explicit_cmd(site_url, attributes)
  Base.build_explicit_colors(val, attributes, quantize)
end

.from_image(image_url) ⇒ Object



16
17
# File 'lib/juice_extractor/core/color_extractor.rb', line 16

def self.from_image(image_url)
end

.implicit_colors(site_url, quantize = nil) ⇒ Object



2
3
4
5
6
7
8
# File 'lib/juice_extractor/core/color_extractor.rb', line 2

def self.implicit_colors(site_url, quantize = nil)
  return [] if site_url.nil? || site_url.empty?
  image_path = Base.screenshot(site_url)
  img = Magick::ImageList.new(image_path)
  img = img.quantize(quantize) if quantize
  img.color_histogram.map{|pixel| pixel.first.to_color(Magick::AllCompliance, false, 8, true) }
end