Class: Swatchman::Image

Inherits:
Object
  • Object
show all
Defined in:
lib/swatchman/image.rb

Instance Method Summary collapse

Constructor Details

#initialize(path_or_url) ⇒ Image

Returns a new instance of Image.



6
7
8
# File 'lib/swatchman/image.rb', line 6

def initialize(path_or_url)
  @resource = MiniMagick::Image.open(path_or_url)
end

Instance Method Details

#palette(size: 3) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/swatchman/image.rb', line 10

def palette(size: 3)
  Swatchman::Palette.new(
    resource.run_command(
      'convert',
      resource.path,
      '-format',
      '%c',
      '-colors',
      size,
      '-depth',
      8,
      'histogram:info:'
    ),
    size
  )
end