Class: FaviconMaker::IcoCommand

Inherits:
Object
  • Object
show all
Includes:
BaseCommand
Defined in:
lib/favicon_maker/commands/ico_command.rb

Instance Method Summary collapse

Methods included from BaseCommand

#compose, #on_windows?, #options_to_args, #to_s

Constructor Details

#initialize(template_file_path, output_file_path, size, options) ⇒ IcoCommand

Returns a new instance of IcoCommand.



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/favicon_maker/commands/ico_command.rb', line 6

def initialize(template_file_path, output_file_path, size, options)

  convert_settings = [
    [ :quiet,       nil      ],
  ]

  center_settings = [
    [ :gravity,     "center" ],
    [ :background,  "none"   ],
  ]

  compose(template_file_path, output_file_path, convert_settings, options, :ico) do |ico_cmd|
    escapes = "\\" unless on_windows?
    size.split(',').sort_by{|s| s.split('x')[0].to_i}.each do |s|
      ico_cmd += [ "#{escapes}( -clone 0 -resize #{s}  #{options_to_args(center_settings)} -extent #{s} #{escapes})" ]
    end
    ico_cmd += [ "-delete 0" ]
  end

end