From 1d41d55f8cd02fbb03d46d56f45f6c77b87842f3 Mon Sep 17 00:00:00 2001 From: Matt Arnold Date: Mon, 8 May 2017 21:33:18 +0100 Subject: [PATCH] Added command line options to disable OptimizeTransLayer and/or OptimizePlusLayer --- lib/screengif.rb | 13 +++++++++---- lib/screengif/options.rb | 10 ++++++++++ 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/lib/screengif.rb b/lib/screengif.rb index 8f9d3c3..0c59af1 100755 --- a/lib/screengif.rb +++ b/lib/screengif.rb @@ -108,10 +108,15 @@ def self.start canvas = canvas.quantize(256, RGBColorspace, NoDitherMethod) $stderr.puts "Quantization completed." if $verbose - $stderr.puts "Beginning rmagick OptimizePlusLayer..." if $verbose - canvas = canvas.optimize_layers(OptimizePlusLayer) - $stderr.puts "Beginning rmagick OptimizeTransLayer..." if $verbose - canvas = canvas.optimize_layers(OptimizeTransLayer) + unless options.no_optimize_pluslayer + $stderr.puts "Beginning rmagick OptimizePlusLayer..." if $verbose + canvas = canvas.optimize_layers(OptimizePlusLayer) + end + + unless options.no_optimize_translayer + $stderr.puts "Beginning rmagick OptimizeTransLayer..." if $verbose + canvas = canvas.optimize_layers(OptimizeTransLayer) + end $stderr.puts "Rmagick processing completed. Outputting results..." if $verbose output = canvas.to_blob diff --git a/lib/screengif/options.rb b/lib/screengif/options.rb index 487836c..9b47327 100644 --- a/lib/screengif/options.rb +++ b/lib/screengif/options.rb @@ -20,6 +20,8 @@ def self.parse(args) options.output_file = nil options.no_gifsicle = false options.fuzz = 5 + options.no_optimize_translayer = false + options.no_optimize_pluslayer = false # options.ffmpeg_inputfile = nil @@ -93,6 +95,14 @@ def self.parse(args) options.no_gifsicle = true end + opts.on("--no-optimize-translayer", "Skip Optimize TransLayer.") do + options.no_optimize_translayer = true + end + + opts.on("--no-optimize-pluslayer", "Skip Optimize PlusLayer.") do + options.no_optimize_pluslayer = true + end + # Boilerplate opts.on_tail("-h", "--help", "Show this message") do puts opts