Sha256: 0ff3d1d3194492aad6cf8c6f072c4f19349c5ff7b57b97749f8f8751dcb7e995

Contents?: true

Size: 885 Bytes

Versions: 2

Compression:

Stored size: 885 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, options = {})
        src.copy(dst)
        args = %W[
          --recompress
          -#{level}
          --quiet
          --
          #{dst}
        ]
        execute(:advpng, args, options) && optimized?(src, dst)
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
image_optim-0.31.1 lib/image_optim/worker/advpng.rb
image_optim-0.31.0 lib/image_optim/worker/advpng.rb