lib/image_optim/worker/pngcrush.rb in image_optim-0.19.1 vs lib/image_optim/worker/pngcrush.rb in image_optim-0.20.0

- old
+ new

@@ -17,28 +17,38 @@ BRUTE_OPTION = option(:brute, false, 'Brute force try all methods, '\ 'very time-consuming and generally not worthwhile'){ |v| !!v } + BLACKEN_OPTION = + option(:blacken, true, 'Blacken fully transparent pixels'){ |v| !!v } + # Always run first [-1] def run_order -1 end def optimize(src, dst) - args = %W[ + flags = %w[ -reduce -cc -q + ] + chunks.each do |chunk| + flags.push '-rem', chunk + end + flags.push '-fix' if fix + flags.push '-brute' if brute + if resolve_bin!(:pngcrush).version >= '1.7.38' + flags.push '-blacken' if blacken + end + + args = flags + %W[ -- #{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 end end end