Class: ImageOptim::Worker::Gifsicle
- Inherits:
-
ImageOptim::Worker
- Object
- ImageOptim::Worker
- ImageOptim::Worker::Gifsicle
- Defined in:
- lib/image_optim/worker/gifsicle.rb
Overview
Constant Summary collapse
- INTERLACE_OPTION =
option(:interlace, false, TrueFalseNil, 'Interlace: ' \ '`true` - interlace on, ' \ '`false` - interlace off, ' \ '`nil` - as is in original image ' \ '(defaults to running two instances, one with interlace off and ' \ 'one with on)') do |v| TrueFalseNil.convert(v) end
- LEVEL_OPTION =
option(:level, 3, 'Compression level: ' \ '`1` - light and fast, ' \ '`2` - normal, ' \ '`3` - heavy (slower)') do |v| OptionHelpers.limit_with_range(v.to_i, 1..3) end
- CAREFUL_OPTION =
option(:careful, false, 'Avoid bugs with some software'){ |v| !!v }
Class Method Summary collapse
-
.init(image_optim, options = {}) ⇒ Object
If interlace specified initialize one instance Otherwise initialize two, one with interlace off and one with on.
Instance Method Summary collapse
Methods inherited from ImageOptim::Worker
#image_formats, #initialize, #inspect, #optimized?, #options, #resolve_used_bins!, #run_order, #used_bins
Methods included from ClassMethods
#bin_sym, #create_all, #create_all_by_format, extended, #inherited, #klasses, #option, #option_definitions
Constructor Details
This class inherits a constructor from ImageOptim::Worker
Class Method Details
.init(image_optim, options = {}) ⇒ Object
If interlace specified initialize one instance Otherwise initialize two, one with interlace off and one with on
11 12 13 14 15 16 17 |
# File 'lib/image_optim/worker/gifsicle.rb', line 11 def self.init(image_optim, = {}) return super if .key?(:interlace) [false, true].map do |interlace| new(image_optim, .merge(interlace: interlace)) end end |
Instance Method Details
#optimize(src, dst, options = {}) ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/image_optim/worker/gifsicle.rb', line 40 def optimize(src, dst, = {}) args = %W[ --output=#{dst} --no-comments --no-names --same-delay --same-loopcount --no-warnings -- #{src} ] if resolve_bin!(:gifsicle).version >= '1.85' args.unshift '--no-extensions', '--no-app-extensions' end unless interlace.nil? args.unshift interlace ? '--interlace' : '--no-interlace' end args.unshift '--careful' if careful args.unshift "--optimize=#{level}" if level execute(:gifsicle, args, ) && optimized?(src, dst) end |