Sha256: b736842c8adf68315072868f7f197af225e471becfb7959cfa1caa00ba59f151

Contents?: true

Size: 897 Bytes

Versions: 6

Compression:

Stored size: 897 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

      # Always run first [-1]
      def run_order
        -1
      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

6 entries across 6 versions & 1 rubygems

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