lib/image_optim/worker/pngcrush.rb in image_optim-0.7.3 vs lib/image_optim/worker/pngcrush.rb in image_optim-0.8.0
- old
+ new
@@ -1,18 +1,16 @@
require 'image_optim/worker'
class ImageOptim
class Worker
class Pngcrush < Worker
- # List of chunks to remove or 'alla' - all except tRNS/transparency or 'allb' - all except tRNS and gAMA/gamma (defaults to 'alla')
- attr_reader :chunks
+ option(:chunks, :alla, Array, 'List of chunks to remove or \'alla\' - all except tRNS/transparency or '\
+ '\'allb\' - all except tRNS and gAMA/gamma'){ |v| Array(v).map(&:to_s) }
- # Fix otherwise fatal conditions such as bad CRCs (defaults to false)
- attr_reader :fix
+ option(:fix, false, 'Fix otherwise fatal conditions such as bad CRCs'){ |v| !!v }
- # Brute force try all methods, very time-consuming and generally not worthwhile (defaults to false)
- attr_reader :brute
+ option(:brute, false, 'Brute force try all methods, very time-consuming and generally not worthwhile'){ |v| !!v }
# Always run first
def run_order
-1
end
@@ -23,17 +21,9 @@
args.unshift '-rem', chunk
end
args.unshift '-fix' if fix
args.unshift '-brute' if brute
execute(:pngcrush, *args) && optimized?(src, dst)
- 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
end
end
end