Class: ImageOptim::Worker::Jpegrecompress
- Inherits:
-
ImageOptim::Worker
- Object
- ImageOptim::Worker
- ImageOptim::Worker::Jpegrecompress
- Defined in:
- lib/image_optim/worker/jpegrecompress.rb
Overview
Constant Summary collapse
- ALLOW_LOSSY_OPTION =
option(:allow_lossy, false, 'Allow worker, it is always lossy'){ |v| !!v }
- QUALITY_NAMES =
[:low, :medium, :high, :veryhigh].freeze
- QUALITY_OPTION =
option(:quality, 3, "JPEG quality preset: #{quality_names_desc}") do |v| OptionHelpers.limit_with_range(v.to_i, 0...QUALITY_NAMES.length) end
- METHOD_OPTION =
option(:method, 'ssim', 'Comparison Metric: ' \ '`mpe` - Mean pixel error, ' \ '`ssim` - Structural similarity, ' \ '`ms-ssim` - Multi-scale structural similarity (slow!), ' \ '`smallfry` - Linear-weighted BBCQ-like (may be patented)') do |v, opt_def| if %w[mpe ssim ms-ssim smallfry].include? v v else warn "Unknown method for jpegrecompress: #{v}" opt_def.default end end
Class Method Summary collapse
-
.init(image_optim, options = {}) ⇒ Object
Initialize only if allow_lossy.
Instance Method Summary collapse
- #optimize(src, dst, options = {}) ⇒ Object
-
#run_order ⇒ Object
Run early as lossy worker.
- #used_bins ⇒ Object
Methods inherited from ImageOptim::Worker
#image_formats, #initialize, #inspect, #optimized?, #options, #resolve_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
Initialize only if allow_lossy
14 15 16 |
# File 'lib/image_optim/worker/jpegrecompress.rb', line 14 def self.init(image_optim, = {}) super if [:allow_lossy] end |
Instance Method Details
#optimize(src, dst, options = {}) ⇒ Object
52 53 54 55 56 57 58 59 60 61 |
# File 'lib/image_optim/worker/jpegrecompress.rb', line 52 def optimize(src, dst, = {}) args = %W[ --quality #{QUALITY_NAMES[quality]} --method #{method} --no-copy #{src} #{dst} ] execute(:'jpeg-recompress', args, ) && optimized?(src, dst) end |
#run_order ⇒ Object
Run early as lossy worker
48 49 50 |
# File 'lib/image_optim/worker/jpegrecompress.rb', line 48 def run_order -5 end |
#used_bins ⇒ Object
43 44 45 |
# File 'lib/image_optim/worker/jpegrecompress.rb', line 43 def used_bins [:'jpeg-recompress'] end |