Class: ImageOptim::Worker::Oxipng
- Inherits:
-
ImageOptim::Worker
- Object
- ImageOptim::Worker
- ImageOptim::Worker::Oxipng
- Defined in:
- lib/image_optim/worker/oxipng.rb
Overview
Constant Summary collapse
- LEVEL_OPTION =
option(:level, 3, 'Optimization level preset: ' \ '`0` is least, ' \ '`6` is best') do |v| OptionHelpers.limit_with_range(v.to_i, 0..6) end
- INTERLACE_OPTION =
option(:interlace, false, TrueFalseNil, 'Interlace: ' \ '`true` - interlace on, ' \ '`false` - interlace off, ' \ '`nil` - as is in original image') do |v| TrueFalseNil.convert(v) end
- STRIP_OPTION =
option(:strip, true, 'Remove all auxiliary chunks'){ |v| !!v }
Instance Method Summary collapse
Methods inherited from ImageOptim::Worker
#image_formats, #initialize, #inspect, #options, #resolve_used_bins!, #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
Instance Method Details
#optimize(src, dst, options = {}) ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/image_optim/worker/oxipng.rb', line 33 def optimize(src, dst, = {}) src.copy(dst) args = %W[ -o #{level} --quiet -- #{dst} ] args.unshift "-i#{interlace ? 1 : 0}" unless interlace.nil? if strip args.unshift '--strip', 'all' end execute(:oxipng, args, ) && optimized?(src, dst) end |
#optimized?(src, dst) ⇒ Boolean
48 49 50 |
# File 'lib/image_optim/worker/oxipng.rb', line 48 def optimized?(src, dst) interlace ? dst.size? : super end |
#run_order ⇒ Object
29 30 31 |
# File 'lib/image_optim/worker/oxipng.rb', line 29 def run_order -4 end |