Sha256: a5c40c409fe1c4d5dbd1f283603cc3fa3ec01f3aacfc53589fc1ee01850ebbd7

Contents?: true

Size: 793 Bytes

Versions: 6

Compression:

Stored size: 793 Bytes

Contents

# frozen_string_literal: true

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 run_order
        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.29.0 lib/image_optim/worker/advpng.rb
image_optim-0.28.0 lib/image_optim/worker/advpng.rb
image_optim-0.27.1 lib/image_optim/worker/advpng.rb
image_optim-0.27.0 lib/image_optim/worker/advpng.rb
image_optim-0.26.5 lib/image_optim/worker/advpng.rb
image_optim-0.26.4 lib/image_optim/worker/advpng.rb