Sha256: 60d49c3a3e542084a80c410525d701f0729261dd24332f63f474e9baf49df44a

Contents?: true

Size: 849 Bytes

Versions: 16

Compression:

Stored size: 849 Bytes

Contents

require 'image_optim/worker'

class ImageOptim
  class Worker
    class Jpegtran < Worker
      option(:copy_chunks, false, 'Copy all chunks'){ |v| !!v }

      option(:progressive, true, 'Create progressive JPEG file'){ |v| !!v }

      option(:jpegrescan, false, 'Use jpegtran through jpegrescan, ignore progressive option'){ |v| !!v }

      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
    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
image_optim-0.13.3 lib/image_optim/worker/jpegtran.rb
image_optim-0.13.2 lib/image_optim/worker/jpegtran.rb
image_optim-0.13.1 lib/image_optim/worker/jpegtran.rb
image_optim-0.13.0 lib/image_optim/worker/jpegtran.rb
image_optim-0.12.1 lib/image_optim/worker/jpegtran.rb
image_optim-0.12.0 lib/image_optim/worker/jpegtran.rb
image_optim-0.11.2 lib/image_optim/worker/jpegtran.rb
image_optim-0.11.1 lib/image_optim/worker/jpegtran.rb
image_optim-0.11.0 lib/image_optim/worker/jpegtran.rb
image_optim-0.10.2 lib/image_optim/worker/jpegtran.rb
image_optim-0.10.1 lib/image_optim/worker/jpegtran.rb
image_optim-0.10.0 lib/image_optim/worker/jpegtran.rb
image_optim-0.9.1 lib/image_optim/worker/jpegtran.rb
image_optim-0.9.0 lib/image_optim/worker/jpegtran.rb
image_optim-0.8.1 lib/image_optim/worker/jpegtran.rb
image_optim-0.8.0 lib/image_optim/worker/jpegtran.rb