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
- TIMEOUT_OPTION =
timeout_option
Class Method Summary collapse
-
.init(image_optim, options = {}) ⇒ Object
Initialize only if allow_lossy.
Instance Method Summary collapse
- #optimize(src, dst) ⇒ 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, #timeout_option
Constructor Details
This class inherits a constructor from ImageOptim::Worker
Class Method Details
.init(image_optim, options = {}) ⇒ Object
Initialize only if allow_lossy
12 13 14 |
# File 'lib/image_optim/worker/jpegrecompress.rb', line 12 def self.init(image_optim, = {}) super if [:allow_lossy] end |
Instance Method Details
#optimize(src, dst) ⇒ Object
38 39 40 41 42 43 44 45 46 |
# File 'lib/image_optim/worker/jpegrecompress.rb', line 38 def optimize(src, dst) args = %W[ --quality #{QUALITY_NAMES[quality]} --no-copy #{src} #{dst} ] execute(:'jpeg-recompress', *args) && optimized?(src, dst) end |
#run_order ⇒ Object
Run early as lossy worker
34 35 36 |
# File 'lib/image_optim/worker/jpegrecompress.rb', line 34 def run_order -5 end |
#used_bins ⇒ Object
29 30 31 |
# File 'lib/image_optim/worker/jpegrecompress.rb', line 29 def used_bins [:'jpeg-recompress'] end |