Sha256: d7b1b8619a4f24f6920853c2948afb2bd8f652c5976ee2fcf6a85b9daccb03d0

Contents?: true

Size: 905 Bytes

Versions: 3

Compression:

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

      TIMEOUT_OPTION = timeout_option

      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

3 entries across 3 versions & 1 rubygems

Version Path
discourse_image_optim-0.26.1 lib/image_optim/worker/pngout.rb
discourse_image_optim-0.24.5 lib/image_optim/worker/pngout.rb
discourse_image_optim-0.24.4 lib/image_optim/worker/pngout.rb