Sha256: 48e1c32aed0f5e858473e05ada6616a8ec1150e7cecbb98976e910e5b6005a0e

Contents?: true

Size: 935 Bytes

Versions: 12

Compression:

Stored size: 935 Bytes

Contents

require 'image_optim'

class ImageOptim
  class Pngcrush < Worker
    # List of chunks to remove or 'alla' or 'allb' (defaults to 'alla')
    attr_reader :chunks

    # Fix otherwise fatal conditions such as bad CRCs (defaults to false)
    attr_reader :fix

    # Brute force try all methods, very time-consuming and generally not worthwhile (defaults to false)
    attr_reader :brute

    # Always run first
    def run_first?
      true
    end

  private

    def parse_options(options)
      get_option!(options, :chunks, :alla){ |v| Array(v).map(&:to_s) }
      get_option!(options, :fix, false){ |v| !!v }
      get_option!(options, :brute, false){ |v| !!v }
    end

    def command_args(src, dst)
      args = %W[-reduce -cc -q -- #{src} #{dst}]
      Array(chunks).each do |chunk|
        args.unshift '-rem', chunk
      end
      args.unshift '-fix' if fix
      args.unshift '-brute' if brute
      args
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
image_optim-0.6.0 lib/image_optim/workers/pngcrush.rb
image_optim-0.5.1 lib/image_optim/workers/pngcrush.rb
image_optim-0.5.0 lib/image_optim/workers/pngcrush.rb
image_optim-0.4.2 lib/image_optim/workers/pngcrush.rb
image_optim-0.4.1 lib/image_optim/workers/pngcrush.rb
image_optim-0.4.0 lib/image_optim/workers/pngcrush.rb
image_optim-0.3.2 lib/image_optim/workers/pngcrush.rb
image_optim-0.3.1 lib/image_optim/workers/pngcrush.rb
image_optim-0.3.0 lib/image_optim/workers/pngcrush.rb
image_optim-0.2.1 lib/image_optim/workers/pngcrush.rb
image_optim-0.2.0 lib/image_optim/workers/pngcrush.rb
image_optim-0.1.0 lib/image_optim/workers/pngcrush.rb