Sha256: c3050044e61136a14ba23b03f41f707a291394d17f94616af876e245b95ce170

Contents?: true

Size: 717 Bytes

Versions: 4

Compression:

Stored size: 717 Bytes

Contents

require 'image_optim/worker'

class ImageOptim
  class Worker
    class Jpegtran < Worker
      # Copy all chunks or none (defaults to false)
      attr_reader :copy_chunks

      # Create progressive JPEG file (defaults to true)
      attr_reader :progressive

      def optimize(src, dst)
        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

    private

      def parse_options(options)
        get_option!(options, :copy_chunks, false){ |v| !!v }
        get_option!(options, :progressive, true){ |v| !!v }
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
image_optim-0.7.3 lib/image_optim/worker/jpegtran.rb
image_optim-0.7.2 lib/image_optim/worker/jpegtran.rb
image_optim-0.7.1 lib/image_optim/worker/jpegtran.rb
image_optim-0.7.0 lib/image_optim/worker/jpegtran.rb