Class: Shellfie::GifPalette

Inherits:
Object
  • Object
show all
Defined in:
lib/shellfie/gif_palette.rb

Instance Method Summary collapse

Constructor Details

#initialize(config:, theme:, command_builder: ImageMagickCommandBuilder) ⇒ GifPalette

Returns a new instance of GifPalette.



8
9
10
11
12
13
# File 'lib/shellfie/gif_palette.rb', line 8

def initialize(config:, theme:, command_builder: ImageMagickCommandBuilder)
  @config = config
  @theme = theme
  @command_builder = command_builder
  @temporary_files = []
end

Instance Method Details

#apply(convert, images: []) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/shellfie/gif_palette.rb', line 15

def apply(convert, images: [])
  convert.dither(dither_mode)

  case @config.animation[:palette]
  when "global"
    apply_global_palette(convert, images)
  when "theme"
    apply_theme_palette(convert)
  else
    convert.colors 256
  end
end

#cleanupObject



28
29
30
31
# File 'lib/shellfie/gif_palette.rb', line 28

def cleanup
  @temporary_files.each { |file| file.close! if file.respond_to?(:close!) }
  @temporary_files.clear
end