Class: ImageOptim::Worker::Pngquant
- Inherits:
-
ImageOptim::Worker
- Object
- ImageOptim::Worker
- ImageOptim::Worker::Pngquant
- Defined in:
- lib/image_optim/worker/pngquant.rb
Overview
Constant Summary collapse
- ALLOW_LOSSY_OPTION =
option(:allow_lossy, false, 'Allow quality option'){ |v| !!v }
- MAX_COLORS_OPTION =
option(:max_colors, 256, 'Maximum number of colors to use') do |v| OptionHelpers.limit_with_range(v.to_i, 2..256) end
- QUALITY_OPTION =
option(:quality, '`100..100`, `0..100` in lossy mode', NonNegativeIntegerRange, 'min..max - don\'t ' \ 'save below min, use less colors below max (both in range `0..100`; ' \ 'in yaml - `!ruby/range 0..100`), ignored in default/lossless ' \ 'mode') do |v, opt_def| if allow_lossy if v == opt_def.default 0..100 else min = OptionHelpers.limit_with_range(v.begin, 0..100) min..OptionHelpers.limit_with_range(v.end, min..100) end else if v != opt_def.default warn "#{self.class.bin_sym} #{opt_def.name} #{v} ignored " \ 'in lossless mode' end 100..100 end end
- SPEED_OPTION =
option(:speed, 3, 'speed/quality trade-off: ' \ '`1` - slow, ' \ '`3` - default, ' \ '`11` - fast & rough') do |v| OptionHelpers.limit_with_range(v.to_i, 1..11) end
Instance Method Summary collapse
Methods inherited from ImageOptim::Worker
#image_formats, #initialize, #inspect, #optimized?, #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
53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/image_optim/worker/pngquant.rb', line 53 def optimize(src, dst, = {}) args = %W[ --quality=#{quality.begin}-#{quality.end} --speed=#{speed} --output=#{dst} --skip-if-larger --force #{max_colors} -- #{src} ] execute(:pngquant, args, ) && optimized?(src, dst) end |
#run_order ⇒ Object
49 50 51 |
# File 'lib/image_optim/worker/pngquant.rb', line 49 def run_order -2 end |