Class: Shellfie::GifPalette
- Inherits:
-
Object
- Object
- Shellfie::GifPalette
- Defined in:
- lib/shellfie/gif_palette.rb
Instance Method Summary collapse
- #apply(convert, images: []) ⇒ Object
- #cleanup ⇒ Object
-
#initialize(config:, theme:, command_builder: ImageMagickCommandBuilder) ⇒ GifPalette
constructor
A new instance of GifPalette.
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 |
#cleanup ⇒ Object
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 |