Sha256: 3c914dcc365b50ac394894e366e342c7a5aec514a5bcb26f5d3656d7f59f4bb2

Contents?: true

Size: 721 Bytes

Versions: 6

Compression:

Stored size: 721 Bytes

Contents

require 'image_optim/worker'
require 'image_optim/option_helpers'

class ImageOptim
  class Worker
    # http://advancemame.sourceforge.net/doc-advpng.html
    class Advpng < Worker
      LEVEL_OPTION =
      option(:level, 4, 'Compression level: '\
          '`0` - don\'t compress, '\
          '`1` - fast, '\
          '`2` - normal, '\
          '`3` - extra, '\
          '`4` - extreme') do |v|
        OptionHelpers.limit_with_range(v.to_i, 0..4)
      end

      def optimize(src, dst)
        src.copy(dst)
        args = %W[
          --recompress
          -#{level}
          --quiet
          --
          #{dst}
        ]
        execute(:advpng, *args) && optimized?(src, dst)
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
image_optim-0.20.2 lib/image_optim/worker/advpng.rb
image_optim-0.20.1 lib/image_optim/worker/advpng.rb
image_optim-0.20.0 lib/image_optim/worker/advpng.rb
image_optim-0.19.1 lib/image_optim/worker/advpng.rb
image_optim-0.19.0 lib/image_optim/worker/advpng.rb
image_optim-0.18.0 lib/image_optim/worker/advpng.rb