Sha256: 2ae934b001c0a3169d9ce251b6a4abad974c23a9c791ea1bbd2c1521af311369

Contents?: true

Size: 703 Bytes

Versions: 12

Compression:

Stored size: 703 Bytes

Contents

require 'image_optim'

class ImageOptim
  class Optipng < Worker
    # Optimization level preset 0..7 (0 is least, 7 is best, defaults to 6)
    attr_reader :level

    # Interlace, true - interlace on, false - interlace off, nil - as is in original image (defaults to false)
    attr_reader :interlace

  private

    def parse_options(options)
      get_option!(options, :level, 6){ |v| limit_with_range(v.to_i, 0..7) }
      get_option!(options, :interlace, false){ |v| v && true }
    end

    def command_args(src, dst)
      src.copy(dst)
      args = %W[-o#{level} -quiet -- #{dst}]
      unless interlace.nil?
        args.unshift "-i#{interlace ? 1 : 0}"
      end
      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/optipng.rb
image_optim-0.5.1 lib/image_optim/workers/optipng.rb
image_optim-0.5.0 lib/image_optim/workers/optipng.rb
image_optim-0.4.2 lib/image_optim/workers/optipng.rb
image_optim-0.4.1 lib/image_optim/workers/optipng.rb
image_optim-0.4.0 lib/image_optim/workers/optipng.rb
image_optim-0.3.2 lib/image_optim/workers/optipng.rb
image_optim-0.3.1 lib/image_optim/workers/optipng.rb
image_optim-0.3.0 lib/image_optim/workers/optipng.rb
image_optim-0.2.1 lib/image_optim/workers/optipng.rb
image_optim-0.2.0 lib/image_optim/workers/optipng.rb
image_optim-0.1.0 lib/image_optim/workers/optipng.rb