class ImageOptim::Worker::Jpegtran

www.ijg.org/

Uses jpegtran through jpegrescan if enabled, jpegrescan is vendored with this gem

Constants

COPY_CHUNKS_OPTION
JPEGRESCAN_OPTION
PROGRESSIVE_OPTION

Public Instance Methods

optimize(src, dst, options = {}) click to toggle source
# File lib/image_optim/worker/jpegtran.rb, line 26
def optimize(src, dst, options = {})
  if jpegrescan
    args = %W[
      #{src}
      #{dst}
    ]
    args.unshift '-s' unless copy_chunks
    resolve_bin!(:jpegtran)
    execute(:jpegrescan, args, options) && 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, options) && optimized?(src, dst)
  end
end
used_bins() click to toggle source
# File lib/image_optim/worker/jpegtran.rb, line 22
def used_bins
  jpegrescan ? [:jpegtran, :jpegrescan] : [:jpegtran]
end