Sha256: 9c1e1d527e6d48a3ffc72d06d101a37acc973eb1982ad1caae0f20b28bc6b9c0
Contents?: true
Size: 1.09 KB
Versions: 4
Compression:
Stored size: 1.09 KB
Contents
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 # 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_order -1 end 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 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
Version data entries
4 entries across 4 versions & 1 rubygems