Class: ImageOptim::Worker::Jpegtran
- Inherits:
-
ImageOptim::Worker
- Object
- ImageOptim::Worker
- ImageOptim::Worker::Jpegtran
- Defined in:
- lib/image_optim/worker/jpegtran.rb
Overview
Uses jpegtran through jpegrescan if enabled, jpegrescan is vendored with this gem
Constant Summary collapse
- COPY_CHUNKS_OPTION =
option(:copy_chunks, false, 'Copy all chunks'){ |v| !!v }
- PROGRESSIVE_OPTION =
option(:progressive, true, 'Create progressive JPEG file'){ |v| !!v }
- JPEGRESCAN_OPTION =
option(:jpegrescan, false, 'Use jpegtran through jpegrescan, '\ 'ignore progressive option'){ |v| !!v }
Instance Method Summary collapse
Methods inherited from ImageOptim::Worker
#<=>, bin_sym, #image_formats, inherited, #initialize, klasses, #optimized?, option, option_definitions, #run_order
Constructor Details
This class inherits a constructor from ImageOptim::Worker
Instance Method Details
#optimize(src, dst) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/image_optim/worker/jpegtran.rb', line 20 def optimize(src, dst) if jpegrescan args = %W[#{src} #{dst}] args.unshift '-s' unless copy_chunks resolve_bin!(:jpegtran) execute(:jpegrescan, *args) && optimized?(src, dst) else args = %W[-optimize -outfile #{dst} #{src}] args.unshift '-copy', copy_chunks ? 'all' : 'none' args.unshift '-progressive' if progressive execute(:jpegtran, *args) && optimized?(src, dst) end end |