Sha256: 02dedbd0ec6dce1e3b1e3678100940d90d6ba3162e96272b67114911d370002b

Contents?: true

Size: 537 Bytes

Versions: 4

Compression:

Stored size: 537 Bytes

Contents

require 'image_optim/worker'

class ImageOptim
  class Worker
    class Advpng < Worker
      # Compression level: 0 - don't compress, 1 - fast, 2 - normal, 3 - extra, 4 - extreme (defaults to 4)
      attr_reader :level

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

    private

      def parse_options(options)
        get_option!(options, :level, 4){ |v| limit_with_range(v.to_i, 0..4) }
      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/advpng.rb
image_optim-0.7.2 lib/image_optim/worker/advpng.rb
image_optim-0.7.1 lib/image_optim/worker/advpng.rb
image_optim-0.7.0 lib/image_optim/worker/advpng.rb