Sha256: ba723ed38100d0c8e611862c0b81994f7d9561a94f5a73d37b109ccca089f950

Contents?: true

Size: 866 Bytes

Versions: 13

Compression:

Stored size: 866 Bytes

Contents

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

class ImageOptim
  class Worker
    # http://www.advsys.net/ken/util/pngout.htm
    class Pngout < Worker
      COPY_CHUNKS_OPTION =
      option(:copy_chunks, false, 'Copy optional chunks'){ |v| !!v }

      STRATEGY_OPTION =
      option(:strategy, 0, 'Strategy: '\
          '`0` - xtreme, '\
          '`1` - intense, '\
          '`2` - longest Match, '\
          '`3` - huffman Only, '\
          '`4` - uncompressed') do |v|
        OptionHelpers.limit_with_range(v.to_i, 0..4)
      end

      def run_order
        2
      end

      def optimize(src, dst)
        args = %W[
          -k#{copy_chunks ? 1 : 0}
          -s#{strategy}
          -q
          -y
          #{src}
          #{dst}
        ]
        execute(:pngout, *args) && optimized?(src, dst)
      end
    end
  end
end

Version data entries

13 entries across 13 versions & 3 rubygems

Version Path
discourse_image_optim-0.26.2 lib/image_optim/worker/pngout.rb
image_optim-0.26.1 lib/image_optim/worker/pngout.rb
image_optim-0.26.0 lib/image_optim/worker/pngout.rb
image_optim-0.25.0 lib/image_optim/worker/pngout.rb
image_optim-0.24.3 lib/image_optim/worker/pngout.rb
image_optim-0.24.2 lib/image_optim/worker/pngout.rb
image_optim-0.24.1 lib/image_optim/worker/pngout.rb
image_optim-0.24.0 lib/image_optim/worker/pngout.rb
image_optim-0.23.0 lib/image_optim/worker/pngout.rb
image_optim-0.22.1 lib/image_optim/worker/pngout.rb
image_optim-0.22.0 lib/image_optim/worker/pngout.rb
openstreetmap-image_optim-0.21.0.1 lib/image_optim/worker/pngout.rb
image_optim-0.21.0 lib/image_optim/worker/pngout.rb