Class: ImageOptim::Worker::Pngcrush

Inherits:
ImageOptim::Worker show all
Defined in:
lib/image_optim/worker/pngcrush.rb

Overview

Constant Summary collapse

CHUNKS_OPTION =
option(:chunks, :alla, Array, 'List of chunks to remove or '\
    '`:alla` - all except tRNS/transparency or '\
    '`:allb` - all except tRNS and gAMA/gamma') do |v|
  Array(v).map(&:to_s)
end
FIX_OPTION =
option(:fix, false, 'Fix otherwise fatal conditions '\
'such as bad CRCs'){ |v| !!v }
BRUTE_OPTION =
option(:brute, false, 'Brute force try all methods, '\
'very time-consuming and generally not worthwhile'){ |v| !!v }

Instance Method Summary collapse

Methods inherited from ImageOptim::Worker

#<=>, bin_sym, #image_formats, inherited, #initialize, klasses, #optimized?, option, option_definitions

Constructor Details

This class inherits a constructor from ImageOptim::Worker

Instance Method Details

#optimize(src, dst) ⇒ Object



27
28
29
30
31
32
33
34
35
# File 'lib/image_optim/worker/pngcrush.rb', line 27

def optimize(src, dst)
  args = %W[-reduce -cc -q -- #{src} #{dst}]
  chunks.each do |chunk|
    args.unshift '-rem', chunk
  end
  args.unshift '-fix' if fix
  args.unshift '-brute' if brute
  execute(:pngcrush, *args) && optimized?(src, dst)
end

#run_orderObject

Always run first [-1]



23
24
25
# File 'lib/image_optim/worker/pngcrush.rb', line 23

def run_order
  -1
end