Sha256: d20f5385d23ca723edce0ce0b3893a9e7146befac714e33587c48d4ed88c1558

Contents?: true

Size: 638 Bytes

Versions: 4

Compression:

Stored size: 638 Bytes

Contents

require 'image_optim/worker'

class ImageOptim
  class Worker
    class Optipng < Worker
      option(:level, 6, 'Optimization level preset 0 is least, 7 is best'){ |v| OptionHelpers.limit_with_range(v.to_i, 0..7) }

      option(:interlace, false, TrueFalseNil, 'Interlace, true - interlace on, false - interlace off, nil - as is in original image') do |v|
        v && true
      end

      def optimize(src, dst)
        src.copy(dst)
        args = %W[-o#{level} -quiet -- #{dst}]
        args.unshift "-i#{interlace ? 1 : 0}" unless interlace.nil?
        execute(:optipng, *args) && optimized?(src, dst)
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
image_optim-0.9.1 lib/image_optim/worker/optipng.rb
image_optim-0.9.0 lib/image_optim/worker/optipng.rb
image_optim-0.8.1 lib/image_optim/worker/optipng.rb
image_optim-0.8.0 lib/image_optim/worker/optipng.rb